mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-05-31 14:11:58 +05:30
Fix permissions page
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
import AuthFlow from 'services/authFlow/AuthFlow';
|
||||
import AbstractState from 'services/authFlow/AbstractState';
|
||||
|
||||
import OAuthState from 'services/authFlow/OAuthState';
|
||||
import RegisterState from 'services/authFlow/RegisterState';
|
||||
import RecoverPasswordState from 'services/authFlow/RecoverPasswordState';
|
||||
import ForgotPasswordState from 'services/authFlow/ForgotPasswordState';
|
||||
import ResendActivationState from 'services/authFlow/ResendActivationState';
|
||||
import LoginState from 'services/authFlow/LoginState';
|
||||
|
||||
// TODO: navigate and state switching
|
||||
|
||||
describe('AuthFlow', () => {
|
||||
@@ -140,4 +147,45 @@ describe('AuthFlow', () => {
|
||||
sinon.assert.calledWithExactly(state.reject, flow, expectedPayload);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#handleRequest()', () => {
|
||||
beforeEach(() => {
|
||||
sinon.stub(flow, 'setState');
|
||||
sinon.stub(flow, 'run');
|
||||
});
|
||||
|
||||
Object.entries({
|
||||
'/': LoginState,
|
||||
'/login': LoginState,
|
||||
'/password': LoginState,
|
||||
'/activation': LoginState,
|
||||
'/change-password': LoginState,
|
||||
'/oauth/permissions': LoginState,
|
||||
'/oauth/finish': LoginState,
|
||||
'/oauth': OAuthState,
|
||||
'/register': RegisterState,
|
||||
'/recover-password': RecoverPasswordState,
|
||||
'/recover-password/key123': RecoverPasswordState,
|
||||
'/forgot-password': ForgotPasswordState,
|
||||
'/resend-activation': ResendActivationState
|
||||
}).forEach(([path, type]) => {
|
||||
it(`should transition to ${type.name} if ${path}`, () => {
|
||||
flow.handleRequest(path);
|
||||
|
||||
sinon.assert.calledOnce(flow.setState);
|
||||
sinon.assert.calledWithExactly(flow.setState, sinon.match.instanceOf(type));
|
||||
});
|
||||
});
|
||||
|
||||
it('should run setOAuthRequest if /', () => {
|
||||
flow.handleRequest('/');
|
||||
|
||||
sinon.assert.calledOnce(flow.run);
|
||||
sinon.assert.calledWithExactly(flow.run, 'setOAuthRequest', {});
|
||||
});
|
||||
|
||||
it('throws if unsupported request', () => {
|
||||
expect(() => flow.handleRequest('/foo/bar')).to.throw('Unsupported request: /foo/bar');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user