Skip to content
This repository was archived by the owner on May 17, 2019. It is now read-only.

Commit 4e06e33

Browse files
authored
Update tests for redux@4 (#102)
* Greenkeep dependencies. * Update failing tests due to new INIT action naming scheme.
1 parent f0e7d8d commit 4e06e33

File tree

3 files changed

+779
-227
lines changed

3 files changed

+779
-227
lines changed

package.json

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
"version": "1.1.0",
55
"license": "MIT",
66
"repository": "fusionjs/fusion-plugin-rpc-redux-react",
7-
"files": ["dist", "src"],
7+
"files": [
8+
"dist",
9+
"src"
10+
],
811
"main": "./dist/index.js",
912
"module": "./dist/index.es.js",
1013
"browser": {
@@ -23,38 +26,38 @@
2326
"fusion-rpc-redux": "^1.0.2"
2427
},
2528
"peerDependencies": {
26-
"fusion-core": "^1.0.2",
27-
"fusion-react": "^1.0.2",
28-
"fusion-tokens": "^1.0.1",
29-
"prop-types": "^15.6.0",
29+
"fusion-core": "^1.2.6",
30+
"fusion-react": "^1.0.4",
31+
"fusion-tokens": "^1.0.3",
32+
"prop-types": "^15.6.1",
3033
"react": "14.x - 16.x"
3134
},
3235
"devDependencies": {
33-
"babel-eslint": "^8.2.2",
36+
"babel-eslint": "^8.2.3",
3437
"babel-plugin-transform-flow-strip-types": "^6.22.0",
35-
"create-universal-package": "^3.4.0",
36-
"eslint": "^4.18.1",
37-
"eslint-config-fusion": "^1.0.0",
38+
"create-universal-package": "^3.4.1",
39+
"eslint": "^4.19.1",
40+
"eslint-config-fusion": "^1.0.1",
3841
"eslint-plugin-cup": "^1.0.0",
39-
"eslint-plugin-flowtype": "^2.45.0",
40-
"eslint-plugin-import": "^2.8.0",
42+
"eslint-plugin-flowtype": "^2.46.3",
43+
"eslint-plugin-import": "^2.11.0",
4144
"eslint-plugin-prettier": "^2.6.0",
4245
"eslint-plugin-react": "^7.7.0",
43-
"flow-bin": "^0.69.0",
44-
"fusion-core": "^1.0.2",
45-
"fusion-plugin-universal-events": "^1.0.2",
46-
"fusion-react": "^1.0.2",
47-
"fusion-react-async": "^1.0.2",
48-
"fusion-test-utils": "^1.0.1",
49-
"fusion-tokens": "^1.0.1",
50-
"nyc": "^11.4.1",
46+
"flow-bin": "^0.71.0",
47+
"fusion-core": "^1.2.6",
48+
"fusion-plugin-universal-events": "^1.0.3",
49+
"fusion-react": "^1.0.4",
50+
"fusion-react-async": "^1.2.2",
51+
"fusion-test-utils": "^1.0.5",
52+
"fusion-tokens": "^1.0.3",
53+
"nyc": "^11.7.1",
5154
"prettier": "1.12.1",
52-
"prop-types": "^15.6.0",
53-
"react": "^16.2.0",
54-
"react-dom": "16.2.0",
55+
"prop-types": "^15.6.1",
56+
"react": "^16.3.2",
57+
"react-dom": "16.3.2",
5558
"react-redux": "^5.0.7",
56-
"react-test-renderer": "^16.2.0",
57-
"redux": "^3.7.2",
59+
"react-test-renderer": "^16.3.2",
60+
"redux": "4.0.0",
5861
"redux-reactors": "^1.0.3",
5962
"tape-cup": "^4.7.1",
6063
"unitest": "^2.1.1"
@@ -64,8 +67,7 @@
6467
"lint": "eslint . --ignore-path .gitignore",
6568
"transpile": "npm run clean && cup build",
6669
"build-test": "rm -rf dist-tests && cup build-tests",
67-
"just-test":
68-
"node_modules/.bin/unitest --browser=dist-tests/browser.js --node=dist-tests/node.js",
70+
"just-test": "node_modules/.bin/unitest --browser=dist-tests/browser.js --node=dist-tests/node.js",
6971
"test": "npm run build-test && npm run just-test",
7072
"cover": "npm run build-test && nyc npm run just-test",
7173
"prepublish": "npm run transpile"

src/__tests__/index.browser.js

Lines changed: 50 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import {mock as RPCPluginMock, RPCHandlersToken} from '../index';
1818
import Plugin from '../plugin';
1919
import {withRPCRedux, withRPCReactor} from '../hoc';
2020

21+
const initActionPattern = /^@@redux\/INIT.*/;
22+
2123
function setup() {
2224
const root = document.createElement('div');
2325
root.id = 'root';
@@ -53,15 +55,17 @@ test('browser plugin integration test withRPCRedux', async t => {
5355
};
5456

5557
const expectedActions = [
56-
{type: '@@redux/INIT'},
57-
{type: 'TEST_START', payload: {hello: 'world'}},
58-
{type: 'TEST_SUCCESS', payload: {a: 'b'}},
58+
{type: initActionPattern},
59+
{type: /TEST_START/, payload: {hello: 'world'}},
60+
{type: /TEST_SUCCESS/, payload: {a: 'b'}},
5961
];
6062
const store = createStore((state, action) => {
63+
const fixture = expectedActions.shift();
64+
t.ok(fixture.type.test(action.type), 'dispatches expected action type');
6165
t.deepLooseEqual(
62-
action,
63-
expectedActions.shift(),
64-
'dispatches expected action'
66+
action.payload,
67+
fixture.payload,
68+
'dispatches expected action payload'
6569
);
6670
return action.payload;
6771
});
@@ -119,18 +123,20 @@ test('browser plugin integration test withRPCRedux - failure', async t => {
119123
};
120124

121125
const expectedActions = [
122-
{type: '@@redux/INIT'},
123-
{type: 'TEST_START', payload: {hello: 'world'}},
126+
{type: initActionPattern},
127+
{type: /TEST_START/, payload: {hello: 'world'}},
124128
{
125-
type: 'TEST_FAILURE',
129+
type: /TEST_FAILURE/,
126130
payload: {message: 'message', code: 'code', meta: {hello: 'world'}},
127131
},
128132
];
129133
const store = createStore((state, action) => {
134+
const fixture = expectedActions.shift();
135+
t.ok(fixture.type.test(action.type), 'dispatches expected action type');
130136
t.deepLooseEqual(
131-
action,
132-
expectedActions.shift(),
133-
'dispatches expected action'
137+
action.payload,
138+
fixture.payload,
139+
'dispatches expected action payload'
134140
);
135141
return action.payload;
136142
});
@@ -176,15 +182,17 @@ test('browser mock integration test withRPCRedux', async t => {
176182
},
177183
};
178184
const expectedActions = [
179-
{type: '@@redux/INIT'},
180-
{type: 'TEST_START', payload: {hello: 'world'}},
181-
{type: 'TEST_SUCCESS', payload: {a: 'b'}},
185+
{type: initActionPattern},
186+
{type: /TEST_START/, payload: {hello: 'world'}},
187+
{type: /TEST_SUCCESS/, payload: {a: 'b'}},
182188
];
183189
const store = createStore((state, action) => {
190+
const fixture = expectedActions.shift();
191+
t.ok(fixture.type.test(action.type), 'dispatches expected action type');
184192
t.deepLooseEqual(
185-
action,
186-
expectedActions.shift(),
187-
'dispatches expected actions'
193+
action.payload,
194+
fixture.payload,
195+
'dispatches expected action payload'
188196
);
189197
return action.payload;
190198
});
@@ -232,18 +240,20 @@ test('browser mock integration test withRPCRedux - failure', async t => {
232240
},
233241
};
234242
const expectedActions = [
235-
{type: '@@redux/INIT'},
236-
{type: 'TEST_START', payload: {hello: 'world'}},
243+
{type: initActionPattern},
244+
{type: /TEST_START/, payload: {hello: 'world'}},
237245
{
238-
type: 'TEST_FAILURE',
246+
type: /TEST_FAILURE/,
239247
payload: {message: 'message', code: 'code', meta: {hello: 'world'}},
240248
},
241249
];
242250
const store = createStore((state, action) => {
251+
const fixture = expectedActions.shift();
252+
t.ok(fixture.type.test(action.type), 'dispatches expected action type');
243253
t.deepLooseEqual(
244-
action,
245-
expectedActions.shift(),
246-
'dispatches expected actions'
254+
action.payload,
255+
fixture.payload,
256+
'dispatches expected action payload'
247257
);
248258
return action.payload;
249259
});
@@ -298,13 +308,12 @@ test('browser plugin integration test withRPCReactor', async t => {
298308
);
299309
};
300310

301-
const expectedActions = [{type: '@@redux/INIT'}];
311+
const expectedActions = [{type: initActionPattern}];
302312
const store = createStore(
303313
(state, action) => {
304-
t.deepLooseEqual(
305-
action,
306-
expectedActions.shift(),
307-
'dispatches expected action'
314+
t.ok(
315+
expectedActions.shift().type.test(action.type),
316+
'dispatches expected action type'
308317
);
309318
return action.payload;
310319
},
@@ -385,13 +394,12 @@ test('browser mock plugin integration test withRPCReactor', async t => {
385394
},
386395
};
387396

388-
const expectedActions = [{type: '@@redux/INIT'}];
397+
const expectedActions = [{type: initActionPattern}];
389398
const store = createStore(
390399
(state, action) => {
391-
t.deepLooseEqual(
392-
action,
393-
expectedActions.shift(),
394-
'dispatches expected action'
400+
t.ok(
401+
expectedActions.shift().type.test(action.type),
402+
'dispatches expected action type'
395403
);
396404
return {};
397405
},
@@ -475,13 +483,12 @@ test('browser plugin integration test withRPCReactor - failure', async t => {
475483
},
476484
};
477485

478-
const expectedActions = [{type: '@@redux/INIT'}];
486+
const expectedActions = [{type: initActionPattern}];
479487
const store = createStore(
480488
(state, action) => {
481-
t.deepLooseEqual(
482-
action,
483-
expectedActions.shift(),
484-
'dispatches expected action'
489+
t.ok(
490+
expectedActions.shift().type.test(action.type),
491+
'dispatches expected action type'
485492
);
486493
return {};
487494
},
@@ -581,13 +588,12 @@ test('browser plugin integration test withRPCReactor - failure 2', async t => {
581588
);
582589
};
583590

584-
const expectedActions = [{type: '@@redux/INIT'}];
591+
const expectedActions = [{type: initActionPattern}];
585592
const store = createStore(
586593
(state, action) => {
587-
t.deepLooseEqual(
588-
action,
589-
expectedActions.shift(),
590-
'dispatches expected action'
594+
t.ok(
595+
expectedActions.shift().type.test(action.type),
596+
'dispatches expected action type'
591597
);
592598
return action.payload;
593599
},

0 commit comments

Comments
 (0)