mirror of
https://github.com/yldio/copilot.git
synced 2024-12-05 01:20:08 +02:00
36 lines
715 B
JavaScript
36 lines
715 B
JavaScript
|
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);
|
||
|
});
|