Skip to content

Commit

Permalink
fix(build): npm updates (#648)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcabrera committed May 18, 2021
1 parent dadb16a commit 01cc3c1
Show file tree
Hide file tree
Showing 10 changed files with 533 additions and 310 deletions.
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"@redhat-cloud-services/frontend-components-notifications": "3.0.3",
"@redhat-cloud-services/frontend-components-utilities": "3.0.3",
"axios": "^0.21.1",
"classnames": "^2.2.6",
"classnames": "^2.3.1",
"i18next": "^19.8.7",
"i18next-xhr-backend": "^3.2.2",
"js-cookie": "^2.2.1",
Expand All @@ -138,11 +138,11 @@
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-i18next": "^11.8.9",
"react-redux": "^7.2.2",
"react-redux": "^7.2.4",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
"redux": "^4.0.5",
"redux": "^4.1.0",
"redux-logger": "^3.0.6",
"redux-promise-middleware": "^6.1.2",
"redux-thunk": "^2.3.0",
Expand All @@ -151,27 +151,27 @@
},
"devDependencies": {
"apidoc-mock": "^3.0.4",
"cspell": "^5.3.7",
"cspell": "^5.3.12",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.6",
"enzyme-to-json": "^3.6.1",
"enzyme-to-json": "^3.6.2",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-prettier": "^7.2.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.1.10",
"eslint-plugin-jsdoc": "^31.6.1",
"eslint-plugin-jest": "^24.3.6",
"eslint-plugin-jsdoc": "^32.3.3",
"eslint-plugin-json": "^2.1.2",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-react": "^7.22.0",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-react": "^7.23.2",
"eslint-plugin-react-hooks": "^4.2.0",
"express": "^4.17.1",
"glob": "^7.1.6",
"moxios": "^0.4.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.2.1",
"redux-mock-store": "^1.5.4",
"standard-version": "^9.1.1",
"standard-version": "^9.2.0",
"swagger-ui-express": "^4.1.6",
"yamljs": "^0.3.0"
},
Expand Down
35 changes: 21 additions & 14 deletions src/common/__tests__/downloadHelpers.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import { downloadHelpers } from '../downloadHelpers';

/**
* ToDo: evaluate the clearing of timers with pending and real
* It's unclear if this is actively helping/necessary...
*/
describe('DownloadHelpers', () => {
// Return a promise, or promise like, response for errors
const returnPromiseAsync = async promiseAsyncCall => {
let response;

try {
response = await promiseAsyncCall();
} catch (e) {
response = e;
}

return response;
};

beforeEach(() => {
jest.useFakeTimers();
});
Expand All @@ -18,18 +27,16 @@ describe('DownloadHelpers', () => {
expect(downloadHelpers).toMatchSnapshot('helpers');
});

it('should throw an error attempting to download data', done => {
downloadHelpers.downloadData().catch(error => {
expect(error).toMatchSnapshot('download error');
done();
});
it('should throw an error attempting to download data', async () => {
const response = await returnPromiseAsync(downloadHelpers.downloadData);

expect(response).toMatchSnapshot('download error');
});

it('should throw an error attempting to access a log', done => {
downloadHelpers.debugLog().catch(error => {
expect(error).toMatchSnapshot('access error');
done();
});
it('should throw an error attempting to access a log', async () => {
const response = await returnPromiseAsync(downloadHelpers.debugLog);

expect(response).toMatchSnapshot('access error');
});

it('should attempt to download data', done => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/chartArea/__tests__/chartArea.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ describe('ChartArea Component', () => {
expect(component.instance().getTooltipData()).toMatchSnapshot('getTooltipData:after function');

component.setProps({
chartTooltip: propsObj => <div id="custom-tooltip">{propsObj.datum}</div>
chartTooltip: ({ datum }) => <div id="custom-tooltip">{datum}</div> // eslint-disable-line react/prop-types
});
expect(component.instance().getTooltipData()).toMatchSnapshot('getTooltipData:after node');

Expand Down
5 changes: 3 additions & 2 deletions src/components/productView/productViewOpenShiftContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,12 +441,13 @@ ProductViewOpenShiftContainer.defaultProps = {
],
initialGraphSettings: {
actionDisplay: data => {
const { coreHours } = data;
let displayContent;

if (data.coreHours) {
if (coreHours) {
let total = 0;

data.coreHours.forEach(({ y }) => {
coreHours.forEach(({ y }) => {
total += y ?? 0;
});

Expand Down
5 changes: 3 additions & 2 deletions src/components/productView/productViewOpenShiftDedicated.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,13 @@ ProductViewOpenShiftDedicated.defaultProps = {
],
initialGraphSettings: {
actionDisplay: data => {
const { coreHours } = data;
let displayContent;

if (data.coreHours) {
if (coreHours) {
let total = 0;

data.coreHours.forEach(({ y }) => {
coreHours.forEach(({ y }) => {
total += y ?? 0;
});

Expand Down
39 changes: 26 additions & 13 deletions src/services/__tests__/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@ import moxios from 'moxios';
import * as service from '../config';

describe('ServiceConfig', () => {
// Return a promise, or promise like, response for errors
const returnPromiseAsync = async promiseAsyncCall => {
let response;

try {
response = await promiseAsyncCall();
} catch (e) {
response = e;
}

return response;
};

beforeAll(() => {
moxios.install();

Expand Down Expand Up @@ -37,21 +50,21 @@ describe('ServiceConfig', () => {
expect(configObject.timeout).toBe(3);
});

it('should handle a bundled authentication and service call', done => {
service.serviceCall({ url: '/test/' }).then(success => {
expect(success.data).toBe('success');
done();
});
it('should handle a bundled authentication and service call', async () => {
const response = await service.serviceCall({ url: '/test/' });

expect(response.data).toBe('success');
});

it('should handle cancelling service calls', done => {
Promise.all([
service.serviceCall({ url: '/test/', cancel: true }),
service.serviceCall({ url: '/test/', cancel: true })
]).catch(error => {
expect(error).toMatchSnapshot('cancelled request');
done();
});
it('should handle cancelling service calls', async () => {
const response = await returnPromiseAsync(() =>
Promise.all([
service.serviceCall({ url: '/test/', cancel: true }),
service.serviceCall({ url: '/test/', cancel: true })
])
);

expect(response).toMatchSnapshot('cancelled request');
});

it('should handle caching service calls', async () => {
Expand Down
70 changes: 35 additions & 35 deletions src/services/__tests__/platformServices.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
import platformServices from '../platformServices';

describe('PlatformServices', () => {
// Return a promise, or promise like, response for errors
const returnPromiseAsync = async promiseAsyncCall => {
let response;

try {
response = await promiseAsyncCall();
} catch (e) {
response = e;
}

return response;
};

it('should export a specific number of methods and classes', () => {
expect(Object.keys(platformServices)).toHaveLength(7);
});
Expand All @@ -19,38 +32,31 @@ describe('PlatformServices', () => {
* timeout errors associated with this test sometimes stem from endpoint
* settings or missing globals, see "before" above, or the "setupTests" config
*/
it('should return async for most methods and resolve successfully', done => {
it('should return async for most methods and resolve successfully', async () => {
const promises = Object.keys(platformServices).map(value => platformServices[value]());
const response = await Promise.all(promises);

Promise.all(promises).then(success => {
expect(success.length).toEqual(Object.keys(platformServices).length);
done();
});
expect(response.length).toEqual(Object.keys(platformServices).length);
});

it('should return a successful getUser', done => {
platformServices.getUser().then(value => {
expect(value).toMatchSnapshot('success authorized user');
done();
});
it('should return a successful getUser', async () => {
const response = await platformServices.getUser();

expect(response).toMatchSnapshot('success authorized user');
});

it('should return a successful getUser with a specific response', done => {
it('should return a successful getUser with a specific response', async () => {
window.insights.chrome.auth.getUser = jest.fn().mockImplementation(() => Promise.resolve('lorem ipsum'));
const response = await platformServices.getUser();

platformServices.getUser().then(value => {
expect(value).toMatchSnapshot('specific success for authorized user');
done();
});
expect(response).toMatchSnapshot('specific success for authorized user');
});

it('should return a failed getUser', done => {
it('should return a failed getUser', async () => {
window.insights.chrome.auth.getUser = undefined;
const response = await returnPromiseAsync(platformServices.getUser);

platformServices.getUser().catch(error => {
expect(error).toMatchSnapshot('failed authorized user');
done();
});
expect(response).toMatchSnapshot('failed authorized user');
});

it('should return a failed getUserPermissions', () => {
Expand All @@ -61,22 +67,18 @@ describe('PlatformServices', () => {
);
});

it('should return a failed hideGlobalFilter', done => {
it('should return a failed hideGlobalFilter', async () => {
window.insights.chrome.hideGlobalFilter = undefined;
const response = await returnPromiseAsync(platformServices.hideGlobalFilter);

platformServices.hideGlobalFilter().catch(error => {
expect(error).toMatchSnapshot('failed hideGlobalFilter');
done();
});
expect(response).toMatchSnapshot('failed hideGlobalFilter');
});

it('should return a failed initializeChrome', done => {
it('should return a failed initializeChrome', async () => {
window.insights.chrome.init = undefined;
const response = await returnPromiseAsync(platformServices.initializeChrome);

platformServices.initializeChrome().catch(error => {
expect(error).toMatchSnapshot('failed initializeChrome');
done();
});
expect(response).toMatchSnapshot('failed initializeChrome');
});

it('should return a failed onNavigation', () => {
Expand All @@ -86,13 +88,11 @@ describe('PlatformServices', () => {
);
});

it('should return a failed setAppName', done => {
it('should return a failed setAppName', async () => {
window.insights.chrome.identifyApp = undefined;
const response = await returnPromiseAsync(platformServices.setAppName);

platformServices.setAppName().catch(error => {
expect(error).toMatchSnapshot('failed setAppName');
done();
});
expect(response).toMatchSnapshot('failed setAppName');
});

it('should return a failed setNavigation', () => {
Expand Down
8 changes: 3 additions & 5 deletions src/services/__tests__/rhsmServices.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@ describe('RhsmServices', () => {
* timeout errors associated with this test sometimes stem from endpoint
* settings or missing globals, see "before" above, or the "setupTests" config
*/
it('should return promises for every method', done => {
it('should return promises for every method', async () => {
const promises = Object.keys(rhsmServices).map(value => rhsmServices[value]());
const response = await Promise.all(promises);

Promise.all(promises).then(success => {
expect(success.length).toEqual(Object.keys(rhsmServices).length);
done();
});
expect(response.length).toEqual(Object.keys(rhsmServices).length);
});
});
Loading

0 comments on commit 01cc3c1

Please sign in to comment.