Skip to content

Commit 76d8c39

Browse files
committedDec 23, 2018
FIX: Some imports / exports had wrong syntax, not supported by Babel 7
1 parent c7cb64a commit 76d8c39

File tree

7 files changed

+1940
-5232
lines changed

7 files changed

+1940
-5232
lines changed
 

‎CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
### V0.9.0
44
- NodeJS updated to the latest LTS version (10.14.2);
55
- NPM dependencies updated to the latest versions. In particular:
6-
- Babel updated from v6 to v7.
6+
- Babel updated from v6 to v7;
7+
- Misc related fixes.
78

89
### v0.8.2
910
- Adds [**`Modal`**](docs/modal.md) component.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Base test 1`] = `
4+
Config {
5+
"SECRET": Object {
6+
"dummySecretKey": "Dummy Secret Value",
7+
},
8+
"dummyKey": "Dummy Value",
9+
}
10+
`;

‎__tests__/shared/utils/config.js

+30-24
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,38 @@
11
/* eslint-env browser */
22

33
import _ from 'lodash';
4+
import config from 'config';
45
import { isClientSide, isServerSide } from 'utils/isomorphy';
56

6-
const CLIENT_SIDE_CONFIG = {
7-
TYPE: 'CLIENT_SIDE_CONFIG',
8-
};
9-
10-
const SERVER_SIDE_CONFIG = {
11-
TYPE: 'SERVER_SIDE_CONFIG',
12-
};
13-
14-
jest.setMock('config', _.clone(SERVER_SIDE_CONFIG));
15-
16-
beforeEach(() => {
17-
jest.resetModules();
18-
window.CONFIG = _.clone(CLIENT_SIDE_CONFIG);
19-
});
20-
21-
afterEach(() => delete window.TRU_FRONT_END);
22-
23-
test('Serves injected config at the client side', () => {
24-
window.TRU_FRONT_END = true;
25-
expect(isClientSide()).toBe(true);
26-
expect(require('utils/config')).toEqual(CLIENT_SIDE_CONFIG);
7+
test('Base test', () => {
8+
expect(config).toMatchSnapshot();
279
});
2810

29-
test('Serves node-config at the server side', () => {
30-
expect(isServerSide()).toBe(true);
31-
expect(require('utils/config')).toEqual(SERVER_SIDE_CONFIG);
11+
describe('Isomorphy behavior tests', () => {
12+
const CLIENT_SIDE_CONFIG = {
13+
TYPE: 'CLIENT_SIDE_CONFIG',
14+
};
15+
16+
const SERVER_SIDE_CONFIG = {
17+
TYPE: 'SERVER_SIDE_CONFIG',
18+
};
19+
20+
beforeEach(() => {
21+
jest.resetModules();
22+
jest.setMock('config', _.clone(SERVER_SIDE_CONFIG));
23+
window.CONFIG = _.clone(CLIENT_SIDE_CONFIG);
24+
});
25+
26+
afterEach(() => delete window.TRU_FRONT_END);
27+
28+
test('Serves injected config at the client side', () => {
29+
window.TRU_FRONT_END = true;
30+
expect(isClientSide()).toBe(true);
31+
expect(require('utils/config').default).toEqual(CLIENT_SIDE_CONFIG);
32+
});
33+
34+
test('Serves node-config at the server side', () => {
35+
expect(isServerSide()).toBe(true);
36+
expect(require('utils/config').default).toEqual(SERVER_SIDE_CONFIG);
37+
});
3238
});

‎package-lock.json

+1,893-5,200
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ let serverUrl = isProdBuild() ? 'prod' : 'dev';
2121
serverUrl = `topcoder-react-utils/dist/${serverUrl}/server`;
2222
const server = utils.isomorphy.isServerSide() ? requireWeak(serverUrl) : null;
2323

24-
module.exports = {
24+
export {
2525
actions,
2626
AppChunk,
2727
Avatar,
@@ -36,5 +36,6 @@ module.exports = {
3636
ScalableRect,
3737
reducers,
3838
server,
39-
...utils,
4039
};
40+
41+
export * from 'utils';

‎src/shared/utils/config.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@ import { isClientSide } from './isomorphy';
1111
import { requireWeak } from './webpack';
1212

1313
/* eslint-disable global-require */
14-
// console.log('IS CLIENT SIDE', isClientSide());
15-
module.exports = isClientSide() ? window.CONFIG : requireWeak('config');
14+
export default isClientSide() ? window.CONFIG : requireWeak('config');
1615
/* eslint-enable global-require */

‎src/shared/utils/redux.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ import { connect } from 'react-redux';
1111
import { isDevBuild } from './isomorphy';
1212

1313
/* Auxiliary aliases. */
14-
module.exports.connect = connect;
15-
module.exports.createActions = createActions;
16-
module.exports.handleActions = handleActions;
14+
export { connect, createActions, handleActions };
1715

1816
/**
1917
* Reduce multiple reducers into a single reducer from left to right.

0 commit comments

Comments
 (0)
Please sign in to comment.