2016-06-10 10:36:21 +05:30
|
|
|
/**
|
|
|
|
* A helpers for testing states in isolation from AuthFlow
|
|
|
|
*/
|
|
|
|
|
2016-03-21 11:46:37 +05:30
|
|
|
export function bootstrap() {
|
|
|
|
const context = {
|
|
|
|
getState: sinon.stub(),
|
|
|
|
run() {},
|
|
|
|
setState() {},
|
2016-08-07 19:24:59 +05:30
|
|
|
getRequest: sinon.stub(),
|
2016-03-21 11:46:37 +05:30
|
|
|
navigate() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
const mock = sinon.mock(context);
|
|
|
|
mock.expects('run').never();
|
|
|
|
mock.expects('navigate').never();
|
|
|
|
mock.expects('setState').never();
|
|
|
|
|
|
|
|
return {context, mock};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function expectState(mock, state) {
|
|
|
|
return mock.expects('setState').once().withExactArgs(
|
|
|
|
sinon.match.instanceOf(state)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function expectNavigate(mock, route) {
|
|
|
|
return mock.expects('navigate').once().withExactArgs(route);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function expectRun(mock, ...args) {
|
|
|
|
return mock.expects('run').once().withExactArgs(...args);
|
|
|
|
}
|