Skip to content

Commit ae2d361

Browse files
committed
update tests for actionCreatorGenerator
1 parent 794f0dc commit ae2d361

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

src/api/internal.spec.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,35 @@ import { resource, page } from '~/data/reduxGen';
55

66
describe('internal', () => {
77
it('generates an action to update one resource', function () {
8-
const dispatch = jest.fn();
9-
108
const config = testConfigOne;
119

1210
const actions = genActions(config);
13-
const oneThunk = actions.one(resource, '23');
14-
oneThunk(dispatch);
11+
const actionOne = actions.one(resource, '23');
1512

16-
expect(dispatch.mock.calls[0][0].resource.label).toBe('nodebalancer-1');
17-
expect(dispatch.mock.calls[0][0].type).toBe('GEN@nodebalancers/ONE');
18-
expect(dispatch.mock.calls[0][0].ids[0]).toBe(23);
13+
expect(actionOne.resource.label).toBe('nodebalancer-1');
14+
expect(actionOne.type).toBe('GEN@nodebalancers/ONE');
15+
expect(actionOne.ids[0]).toBe(23);
1916
});
2017

2118
it('generates an action to update many resources', function () {
22-
const dispatch = jest.fn();
23-
2419
const config = testConfigMany;
2520

2621
const actions = genActions(config);
27-
const manyThunk = actions.many(page);
28-
manyThunk(dispatch);
29-
expect(dispatch.mock.calls[0][0].page.nodebalancers[0].label)
22+
const actionMany = actions.many(page);
23+
24+
expect(actionMany.page.nodebalancers[0].label)
3025
.toBe('nodebalancer-1');
31-
expect(dispatch.mock.calls[0][0].page.nodebalancers[1].label)
26+
expect(actionMany.page.nodebalancers[1].label)
3227
.toBe('nodebalancer-2');
33-
expect(dispatch.mock.calls[0][0].type).toBe('GEN@nodebalancers/MANY');
28+
expect(actionMany.type).toBe('GEN@nodebalancers/MANY');
3429
});
3530

3631
it('generates an action to delete a resource', function () {
3732
const config = testConfigDelete;
3833

3934
const actions = genActions(config);
4035
const deleteAction = actions.delete('23');
36+
4137
expect(deleteAction.ids[0]).toBe(23);
4238
expect(deleteAction.type).toBe('GEN@nodebalancers/DELETE');
4339
});

0 commit comments

Comments
 (0)