Skip to content

Instantly share code, notes, and snippets.

@sapegin

sapegin/sinon.js Secret

Created June 13, 2016 09:39
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sapegin/6d28bc3da647dce36b2f99072f0f542b to your computer and use it in GitHub Desktop.
Save sapegin/6d28bc3da647dce36b2f99072f0f542b to your computer and use it in GitHub Desktop.
it('load() should load data from the API', (done) => {
const firstAction = {
type: 'kao/simple/RECEIVING',
};
const secondAction = {
type: 'kao/simple/RECEIVE',
data: singleItem,
};
mockUrl('/api.json', singleItem);
let duck = defineRemoteEndpoint(simpleParams);
let load = duck.actions.load();
let count = 0;
let dispatch = sinon.spy(() => {
if (++count !== 2) {
return;
}
try {
expect(dispatch.firstCall.args).to.eql([firstAction]);
expect(dispatch.secondCall.args).to.eql([secondAction]);
done();
}
catch (e) {
done(e);
}
});
load(dispatch);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment