Fix bug with infinite loader, when page refreshed on /login with oauth state restoration active

This commit is contained in:
SleepWalker
2016-10-25 09:32:50 +03:00
parent abf5fbbef6
commit 28ce3e4b70
3 changed files with 15 additions and 5 deletions

View File

@@ -58,7 +58,8 @@ describe('AuthFlow', () => {
}));
sinon.stub(flow, 'run').named('flow.run');
flow.run.returns({then: (fn) => fn()});
const promiseLike = {then: (fn) => fn() || promiseLike};
flow.run.returns(promiseLike);
sinon.stub(flow, 'setState').named('flow.setState');
});
@@ -96,6 +97,14 @@ describe('AuthFlow', () => {
expect(flow.setState, 'was called once');
});
it('should call onReady after state restoration', () => {
const onReady = sinon.stub().named('onReady');
flow.handleRequest({path: '/login'}, null, onReady);
expect(onReady, 'was called');
});
it('should not restore oauth state for /register route', () => {
flow.handleRequest({path: '/register'});