1
0
mirror of https://github.com/yldio/copilot.git synced 2024-12-01 07:30:07 +02:00
copilot/frontend/test/thunks/app.js

36 lines
715 B
JavaScript
Raw Normal View History

2016-12-20 13:29:54 +02:00
const mock = require('simple-mock');
const test = require('ava');
const thunks = require('@state/thunks');
const {
transitionTo
} = thunks;
test('transitionTo should dispatch', (t) => {
const pathname = '/hello';
const state = {
app: {
router: {
transitionTo: mock.spy((pathname) => pathname)
}
}
};
const dispatch = mock.spy(({
PAYLOAD
}) => {
t.deepEqual(PAYLOAD, pathname);
});
const getState = () => state;
transitionTo(pathname)(dispatch, getState);
t.deepEqual(dispatch.called, true);
t.deepEqual(dispatch.callCount, 1);
t.deepEqual(state.app.router.transitionTo.called, true);
t.deepEqual(state.app.router.transitionTo.callCount, 1);
});