Skip to content

Commit 857bbd5

Browse files
committed
Upgrading packages that required ESM.
1 parent f52b51e commit 857bbd5

File tree

12 files changed

+148
-187
lines changed

12 files changed

+148
-187
lines changed

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"build": "npm run clean && npm run build:server && npm run build:client",
1818
"build:test": "npm run clean && npm run build:server && npm run build:client",
1919
"lint": "eslint src",
20-
"test": "mocha --recursive --timeout 2000 --require @babel/register --require ./test/setup.js --require mock-local-storage",
20+
"test": "mocha --recursive --timeout 2000 --require ./test/setup.js --require mock-local-storage",
2121
"test:mocha": "mocha --recursive --timeout 2000 --require @babel/register --require ./test/setup.js --require mock-local-storage",
2222
"test:watch": "mocha --recursive --timeout 2000 --require @babel/register --require ./test/setup.js --require mock-local-storage --watch --reporter nyan",
2323
"dev": "babel-node bin/dev.js --max-old-space-size=4096",
@@ -53,11 +53,11 @@
5353
"ejs": "^3.1.10",
5454
"express": "^4.19.2",
5555
"file-saver": "^2.0.5",
56-
"flat": "^5.0.2",
56+
"flat": "^6.0.1",
5757
"font-awesome-animation": "^1.1.1",
58-
"glob": "^10.4.2",
58+
"glob": "^10.4.3",
5959
"global": "^4.4.0",
60-
"highlight.js": "^11.9.0",
60+
"highlight.js": "^11.10.0",
6161
"immutable": "^4.3.6",
6262
"jwt-decode": "^4.0.0",
6363
"markdown-it": "^14.1.0",
@@ -85,7 +85,7 @@
8585
"react-syntax-highlighter": "^15.5.0",
8686
"react-toggle": "4.1.3",
8787
"redux": "^5.0.1",
88-
"redux-actions": "^2.6.5",
88+
"redux-actions": "^3.0.0",
8989
"redux-form": "^8.3.10",
9090
"redux-promise-middleware": "^6.2.0",
9191
"redux-storage": "^4.1.2",
@@ -121,7 +121,7 @@
121121
"babel-preset-react": "^6.24.1",
122122
"babel-preset-stage-1": "^6.24.1",
123123
"babel-regenerator-runtime": "^6.5.0",
124-
"chai": "^4.4.1",
124+
"chai": "^5.1.1",
125125
"chai-spies": "^1.1.0",
126126
"colors": "^1.4.0",
127127
"core-js": "^3.37.1",

src/redux/helpers/api/tools.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import statusCode from 'statuscode';
2-
import flatten from 'flat';
2+
import { flatten } from 'flat';
33
import { Buffer } from 'buffer';
44

55
import { addNotification } from '../../modules/notifications.js';

test/chai-spy.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { use } from 'chai';
2+
import spies from 'chai-spies';
3+
4+
export default use(spies);

test/redux/helpers/resourceManager/actionCreators-test.js

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
import chai from 'chai';
2-
import spies from 'chai-spies';
31
import { fromJS } from 'immutable';
4-
52
import actionTypesFactory from '../../../../src/redux/helpers/resourceManager/actionTypesFactory.js';
63
import actionCreatorsFactory from '../../../../src/redux/helpers/resourceManager/actionCreatorsFactory.js';
74

8-
chai.use(spies);
9-
const expect = chai.expect;
5+
import chai from '../../../chai-spy.js';
106

117
// prepared spies
128
let globalNeedsRefetching = false; // this is really disgusting, I know...
@@ -39,13 +35,13 @@ describe('Resource manager', () => {
3935
const { fetchResource } = actionCreators;
4036

4137
// fetchResource must be a function with one parameter
42-
expect(fetchResource).to.be.a('function');
43-
expect(fetchResource.length).to.equal(1);
38+
chai.expect(fetchResource).to.be.a('function');
39+
chai.expect(fetchResource.length).to.equal(1);
4440

4541
// calling fetchResource will create an action through the 'createApiAction' function
4642
fetchResource('abc');
47-
expect(createApiAction).to.have.been.called.once;
48-
expect(createApiAction).to.have.been.called.with({
43+
chai.expect(createApiAction).to.have.been.called.once;
44+
chai.expect(createApiAction).to.have.been.called.with({
4945
type: actionTypes.FETCH,
5046
method: 'GET',
5147
endpoint: 'url/abc',
@@ -57,13 +53,13 @@ describe('Resource manager', () => {
5753
const { fetchOneIfNeeded } = actionCreators;
5854

5955
// fetchResource must be a function with one parameter
60-
expect(fetchOneIfNeeded).to.be.a('function');
61-
expect(fetchOneIfNeeded.length).to.equal(1);
56+
chai.expect(fetchOneIfNeeded).to.be.a('function');
57+
chai.expect(fetchOneIfNeeded.length).to.equal(1);
6258

6359
// calling fetchResource will create a thunk
6460
const thunk = fetchOneIfNeeded('abc');
65-
expect(thunk).to.be.a('function');
66-
expect(thunk.length).to.equal(2);
61+
chai.expect(thunk).to.be.a('function');
62+
chai.expect(thunk.length).to.equal(2);
6763

6864
const getState = () =>
6965
fromJS({
@@ -76,8 +72,8 @@ describe('Resource manager', () => {
7672
const dispatch = chai.spy();
7773
const thunkResult = thunk(dispatch, getState);
7874

79-
expect(dispatch).to.not.have.been.called();
80-
expect(thunkResult.then).to.be.a('function');
75+
chai.expect(dispatch).to.not.have.been.called();
76+
chai.expect(thunkResult.then).to.be.a('function');
8177
thunkResult.then(() => done()); // must be resolved right away
8278
});
8379

@@ -96,8 +92,8 @@ describe('Resource manager', () => {
9692
const dispatch = chai.spy();
9793
thunk(dispatch, getState); // we don't care about the resulting state in this test
9894

99-
expect(dispatch).to.have.been.called.once;
100-
expect(dispatch).to.have.been.called.with(fetchResource('abc'));
95+
chai.expect(dispatch).to.have.been.called.once;
96+
chai.expect(dispatch).to.have.been.called.with(fetchResource('abc'));
10197
});
10298
});
10399

@@ -106,13 +102,13 @@ describe('Resource manager', () => {
106102
const { fetchMany } = actionCreators;
107103

108104
// fetchResource must be a function with one parameter
109-
expect(fetchMany).to.be.a('function');
110-
expect(fetchMany.length).to.equal(1);
105+
chai.expect(fetchMany).to.be.a('function');
106+
chai.expect(fetchMany.length).to.equal(1);
111107

112108
// calling fetchResource will create an action through the 'createApiAction' function
113109
fetchMany({});
114-
expect(createApiAction).to.have.been.called.once;
115-
expect(createApiAction).to.have.been.called.with({
110+
chai.expect(createApiAction).to.have.been.called.once;
111+
chai.expect(createApiAction).to.have.been.called.with({
116112
type: actionTypes.FETCH_MANY,
117113
method: 'GET',
118114
endpoint: 'url/',
@@ -124,14 +120,14 @@ describe('Resource manager', () => {
124120
it('must create an "add resource" action creator', () => {
125121
const { addResource } = actionCreators;
126122

127-
expect(addResource).to.be.a('function');
128-
expect(addResource.length).to.equal(1);
123+
chai.expect(addResource).to.be.a('function');
124+
chai.expect(addResource.length).to.equal(1);
129125

130126
const body = { foo: 'bar', abc: 'xyz' };
131127
const tmpId = 'random-tmp-id';
132128
addResource(body, tmpId);
133-
expect(createApiAction).to.have.been.called.once;
134-
expect(createApiAction).to.have.been.called.with({
129+
chai.expect(createApiAction).to.have.been.called.once;
130+
chai.expect(createApiAction).to.have.been.called.with({
135131
type: actionTypes.ADD,
136132
method: 'POST',
137133
endpoint: 'url/',
@@ -150,14 +146,14 @@ describe('Resource manager', () => {
150146
it('must create an "update resource" action creator', () => {
151147
const { updateResource } = actionCreators;
152148

153-
expect(updateResource).to.be.a('function');
154-
expect(updateResource.length).to.equal(2);
149+
chai.expect(updateResource).to.be.a('function');
150+
chai.expect(updateResource.length).to.equal(2);
155151

156152
const body = { foo: 'bar', abc: 'xyz' };
157153
const id = 'some-id';
158154
updateResource(id, body);
159-
expect(createApiAction).to.have.been.called.once;
160-
expect(createApiAction).to.have.been.called.with({
155+
chai.expect(createApiAction).to.have.been.called.once;
156+
chai.expect(createApiAction).to.have.been.called.with({
161157
type: actionTypes.UPDATE,
162158
method: 'POST',
163159
endpoint: `url/${id}`,
@@ -171,13 +167,13 @@ describe('Resource manager', () => {
171167
it('must create an "remove resource" action creator', () => {
172168
const { removeResource } = actionCreators;
173169

174-
expect(removeResource).to.be.a('function');
175-
expect(removeResource.length).to.equal(1);
170+
chai.expect(removeResource).to.be.a('function');
171+
chai.expect(removeResource.length).to.equal(1);
176172

177173
const id = 'some-id';
178174
removeResource(id);
179-
expect(createApiAction).to.have.been.called.once;
180-
expect(createApiAction).to.have.been.called.with({
175+
chai.expect(createApiAction).to.have.been.called.once;
176+
chai.expect(createApiAction).to.have.been.called.with({
181177
type: actionTypes.REMOVE,
182178
method: 'DELETE',
183179
endpoint: `url/${id}`,

test/redux/helpers/resourceManager/createRecord-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import createRecord from '../../../../src/redux/helpers/resourceManager/recordFactory.js';
22
import { resourceStatus } from '../../../../src/redux/helpers/resourceManager/status.js';
3-
import chai from 'chai';
3+
import * as chai from 'chai';
44
import chaiImmutable from 'chai-immutable';
55
chai.use(chaiImmutable);
66
const expect = chai.expect;
@@ -23,7 +23,7 @@ describe('Resource manager', () => {
2323
state: 'WHATEVER!!',
2424
didInvalidate: true,
2525
lastUpdate: Date.now() + 1000000,
26-
data: 'not null'
26+
data: 'not null',
2727
};
2828
const record = createRecord(cfg);
2929
expect(record.get('state')).to.equal(cfg.state);
@@ -43,8 +43,8 @@ describe('Resource manager', () => {
4343
items: ['a', 'b', 'c'],
4444
nested: {
4545
child: 'CHILD',
46-
list: ['x', 'y', { p: 'q' }]
47-
}
46+
list: ['x', 'y', { p: 'q' }],
47+
},
4848
};
4949
const record = createRecord({ data });
5050
expect(record.get('data')).to.be.an('object');

test/redux/middleware/apiMiddleware-test.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
import chai from 'chai';
2-
import spies from 'chai-spies';
31
import fetchMock from 'fetch-mock';
2+
import chai from '../../chai-spy.js';
43
import middleware, { CALL_API, createApiAction } from '../../../src/redux/middleware/apiMiddleware.js';
54
import { API_BASE } from '../../../src/helpers/config.js';
65

7-
chai.use(spies);
8-
const expect = chai.expect;
9-
106
describe('API middleware and helper functions', () => {
117
it('must create correct api call action', () => {
128
const action = createApiAction({ type: 'TYPE', payload: 'payload' });
13-
expect(action).to.eql({
9+
chai.expect(action).to.eql({
1410
type: CALL_API,
1511
request: {
1612
type: 'TYPE',
@@ -22,7 +18,7 @@ describe('API middleware and helper functions', () => {
2218
describe('(Middleware)', () => {
2319
it('must throw an error when an API call action without request info is dispatched', () => {
2420
const action = { type: CALL_API, randomData: 'blabla' };
25-
expect(() => middleware(null)(null)(action)).to.throw();
21+
chai.expect(() => middleware(null)(null)(action)).to.throw();
2622
});
2723

2824
it('must intersect API call actions and create request', done => {
@@ -48,19 +44,19 @@ describe('API middleware and helper functions', () => {
4844
alteredAction.payload.promise.then(resp => {
4945
try {
5046
// exactly one dispatch incrementing and one decrementing the number of pending api calls ...
51-
expect(dispatchSpy).to.have.been.called.twice;
47+
chai.expect(dispatchSpy).to.have.been.called.twice;
5248

5349
// examine the HTTP request
54-
expect(fetchMock.calls('matched').length).to.equal(1);
55-
expect(fetchMock.calls('unmatched').length).to.equal(0);
50+
chai.expect(fetchMock.calls('matched').length).to.equal(1);
51+
chai.expect(fetchMock.calls('unmatched').length).to.equal(0);
5652
const [url, req] = fetchMock.calls('matched').pop();
57-
expect(url).to.equal(endpoint);
58-
expect(req.method.toLowerCase()).to.equal('get');
53+
chai.expect(url).to.equal(endpoint);
54+
chai.expect(req.method.toLowerCase()).to.equal('get');
5955
fetchMock.restore();
6056

6157
// examine the NEXT call
62-
expect(spy).to.have.been.called();
63-
expect(spy).to.have.been.called.once;
58+
chai.expect(spy).to.have.been.called();
59+
chai.expect(spy).to.have.been.called.once;
6460

6561
fetchMock.restore();
6662
done();
Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { fromJS } from 'immutable';
2+
import chai from '../../chai-spy.js';
23
import { createApiAction } from '../../../src/redux/middleware/apiMiddleware.js';
34
import { actionTypes as authActionTypes } from '../../../src/redux/modules/auth.js';
45

@@ -9,12 +10,6 @@ import middleware, {
910
getToken,
1011
} from '../../../src/redux/middleware/authMiddleware.js';
1112

12-
import chai from 'chai';
13-
import spies from 'chai-spies';
14-
15-
chai.use(spies);
16-
const expect = chai.expect;
17-
1813
describe('Middleware for access token storage and injecting to HTTP requests', () => {
1914
afterEach(() => {
2015
localStorage.clear();
@@ -24,23 +19,23 @@ describe('Middleware for access token storage and injecting to HTTP requests', (
2419
describe('(Local storage manipulation)', () => {
2520
it('must store the token in localStorage', () => {
2621
localStorage.removeItem(TOKEN_LOCAL_STORAGE_KEY);
27-
expect(localStorage.getItem(TOKEN_LOCAL_STORAGE_KEY)).to.equal(null);
22+
chai.expect(localStorage.getItem(TOKEN_LOCAL_STORAGE_KEY)).to.equal(null);
2823
storeToken('abcd');
29-
expect(localStorage.getItem(TOKEN_LOCAL_STORAGE_KEY)).to.equal('abcd');
24+
chai.expect(localStorage.getItem(TOKEN_LOCAL_STORAGE_KEY)).to.equal('abcd');
3025
});
3126

3227
it('must fetch the token in localStorage', () => {
3328
localStorage.removeItem(TOKEN_LOCAL_STORAGE_KEY);
34-
expect(localStorage.getItem(TOKEN_LOCAL_STORAGE_KEY)).to.equal(null);
29+
chai.expect(localStorage.getItem(TOKEN_LOCAL_STORAGE_KEY)).to.equal(null);
3530
localStorage.setItem(TOKEN_LOCAL_STORAGE_KEY, 'hchkrdtn');
36-
expect(getToken()).to.equal('hchkrdtn');
31+
chai.expect(getToken()).to.equal('hchkrdtn');
3732
});
3833

3934
it('must remove the token from localStorage', () => {
4035
localStorage.setItem(TOKEN_LOCAL_STORAGE_KEY, 'abcdefgh');
41-
expect(localStorage.getItem(TOKEN_LOCAL_STORAGE_KEY)).to.equal('abcdefgh');
36+
chai.expect(localStorage.getItem(TOKEN_LOCAL_STORAGE_KEY)).to.equal('abcdefgh');
4237
removeToken();
43-
expect(localStorage.getItem(TOKEN_LOCAL_STORAGE_KEY)).to.equal(null);
38+
chai.expect(localStorage.getItem(TOKEN_LOCAL_STORAGE_KEY)).to.equal(null);
4439
});
4540
});
4641

@@ -50,7 +45,7 @@ describe('Middleware for access token storage and injecting to HTTP requests', (
5045
it('must intersect LOGIN action and store the accessToken in the payload', () => {
5146
// clean the storage first
5247
localStorage.removeItem(TOKEN_LOCAL_STORAGE_KEY);
53-
expect(localStorage.getItem(TOKEN_LOCAL_STORAGE_KEY)).to.equal(null);
48+
chai.expect(localStorage.getItem(TOKEN_LOCAL_STORAGE_KEY)).to.equal(null);
5449

5550
const action = {
5651
type: authActionTypes.LOGIN_FULFILLED,
@@ -69,8 +64,8 @@ describe('Middleware for access token storage and injecting to HTTP requests', (
6964

7065
const store = createFakeStore();
7166
middleware(store)(a => a)(action);
72-
expect(localStorage.getItem(TOKEN_LOCAL_STORAGE_KEY)).to.equal('abcdefgh');
73-
expect(store.dispatch).to.have.been.called.once;
67+
chai.expect(localStorage.getItem(TOKEN_LOCAL_STORAGE_KEY)).to.equal('abcdefgh');
68+
chai.expect(store.dispatch).to.have.been.called.once;
7469
});
7570

7671
it('must intersect LOGOUT action and remove the accessToken from the local storage', () => {
@@ -82,21 +77,23 @@ describe('Middleware for access token storage and injecting to HTTP requests', (
8277

8378
const store = createFakeStore();
8479
middleware(store)(a => a)(action);
85-
expect(localStorage.getItem(TOKEN_LOCAL_STORAGE_KEY)).to.equal(null);
80+
chai.expect(localStorage.getItem(TOKEN_LOCAL_STORAGE_KEY)).to.equal(null);
8681
});
8782

8883
it('must intersect the CALL_API action and add access token to the request (if any)', () => {
8984
const action = createApiAction({});
9085
const accessToken = 'abcdefgh';
91-
expect(
92-
middleware({
93-
getState: () => ({
94-
auth: fromJS({
95-
jwt: accessToken,
86+
chai
87+
.expect(
88+
middleware({
89+
getState: () => ({
90+
auth: fromJS({
91+
jwt: accessToken,
92+
}),
9693
}),
97-
}),
98-
})(a => a)(action).request
99-
).to.eql({ accessToken });
94+
})(a => a)(action).request
95+
)
96+
.to.eql({ accessToken });
10097
});
10198
});
10299
});

test/redux/modules/auth-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import chai from 'chai';
1+
import * as chai from 'chai';
22
import spies from 'chai-spies';
33
import { fromJS } from 'immutable';
44

test/redux/modules/evaluationProgress-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import chai from 'chai';
1+
import * as chai from 'chai';
22
import spies from 'chai-spies';
33
import { Map, List } from 'immutable';
44

0 commit comments

Comments
 (0)