Skip to content

Commit

Permalink
Put single array argument into its own test
Browse files Browse the repository at this point in the history
  • Loading branch information
wswoodruff committed Jul 28, 2020
1 parent c4c181f commit d4ac480
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions test/actions.js
Expand Up @@ -105,18 +105,33 @@ describe('Actions', () => {
]);

expect(results).to.equal([null, { id: 1 }]);
});

it('preserves special case single array arguments.', async () => {

const store = createActionRecordingStore();

// Extra check for special case — single array arg
const arrayResults = await store.dispatch(actionX([{ id: 2 }, { id: 3 }]));
const { X } = MiddleEnd.createTypes({
X: MiddleEnd.type.async
});

const actionX = MiddleEnd.createAction(X, {

handler: (...args) => {

expect(args).to.equal([[{ id: 1 }, { id: 2 }]]);
return args;
}
});

const results = await store.dispatch(actionX([{ id: 1 }, { id: 2 }]));

expect(store.getState()).to.equal([
{ type: X.BEGIN, payload: { id: 1 }, meta: { index: null } },
{ type: X.SUCCESS, payload: { id: 1 }, meta: { index: null, original: { id: 1 } } },
{ type: X.BEGIN, payload: [[{ id: 2 }, { id: 3 }]], meta: { index: null } },
{ type: X.SUCCESS, payload: [[{ id: 2 }, { id: 3 }]], meta: { index: null, original: [[{ id: 2 }, { id: 3 }]] } }
{ type: X.BEGIN, payload: [[{ id: 1 }, { id: 2 }]], meta: { index: null } },
{ type: X.SUCCESS, payload: [[{ id: 1 }, { id: 2 }]], meta: { index: null, original: [[{ id: 1 }, { id: 2 }]] } }
]);

expect(arrayResults).to.equal([null, [[{ id: 2 }, { id: 3 }]]]);
expect(results).to.equal([null, [[{ id: 1 }, { id: 2 }]]]);
});

it('creates an async action with a handler that succeeds.', async () => {
Expand Down

0 comments on commit d4ac480

Please sign in to comment.