mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-11-14 20:25:56 +05:30
Resend activation from register state
This commit is contained in:
parent
09ca1aa85a
commit
05b82101bf
@ -1,5 +1,6 @@
|
||||
import AbstractState from './AbstractState';
|
||||
import CompleteState from './CompleteState';
|
||||
import ResendActivationState from './ResendActivationState';
|
||||
|
||||
export default class RegisterState extends AbstractState {
|
||||
enter(context) {
|
||||
@ -18,5 +19,6 @@ export default class RegisterState extends AbstractState {
|
||||
}
|
||||
|
||||
reject(context) {
|
||||
context.setState(new ResendActivationState());
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,16 @@
|
||||
import AbstractState from './AbstractState';
|
||||
import CompleteState from './CompleteState';
|
||||
import ActivationState from './ActivationState';
|
||||
import RegisterState from './RegisterState';
|
||||
|
||||
export default class ResendActivationState extends AbstractState {
|
||||
enter(context) {
|
||||
const {user} = context.getState();
|
||||
|
||||
if (user.isActive) {
|
||||
if (user.isActive && !user.isGuest) {
|
||||
context.setState(new CompleteState());
|
||||
} else {
|
||||
context.navigate('/repeat-message');
|
||||
context.navigate('/resend-activation');
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,6 +20,12 @@ export default class ResendActivationState extends AbstractState {
|
||||
}
|
||||
|
||||
goBack(context) {
|
||||
context.setState(new ActivationState());
|
||||
const {user} = context.getState();
|
||||
|
||||
if (user.isGuest) {
|
||||
context.setState(new RegisterState());
|
||||
} else {
|
||||
context.setState(new ActivationState());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
import RegisterState from 'services/authFlow/RegisterState';
|
||||
import CompleteState from 'services/authFlow/CompleteState';
|
||||
import ResendActivationState from 'services/authFlow/ResendActivationState';
|
||||
|
||||
import { bootstrap, expectState, expectNavigate, expectRun } from './helpers';
|
||||
|
||||
@ -78,4 +79,12 @@ describe('RegisterState', () => {
|
||||
return promise.catch(mock.verify.bind(mock));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#reject', () => {
|
||||
it('should transition to resend-activation', () => {
|
||||
expectState(mock, ResendActivationState);
|
||||
|
||||
state.reject(context);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,6 +1,7 @@
|
||||
import ResendActivationState from 'services/authFlow/ResendActivationState';
|
||||
import CompleteState from 'services/authFlow/CompleteState';
|
||||
import ActivationState from 'services/authFlow/ActivationState';
|
||||
import RegisterState from 'services/authFlow/RegisterState';
|
||||
|
||||
import { bootstrap, expectState, expectNavigate, expectRun } from './helpers';
|
||||
|
||||
@ -35,6 +36,19 @@ describe('ResendActivationState', () => {
|
||||
state.enter(context);
|
||||
});
|
||||
|
||||
it('should navigate to /resend-activation for guests', () => {
|
||||
context.getState.returns({
|
||||
user: {
|
||||
isGuest: true,
|
||||
isActive: true
|
||||
}
|
||||
});
|
||||
|
||||
expectNavigate(mock, '/resend-activation');
|
||||
|
||||
state.enter(context);
|
||||
});
|
||||
|
||||
it('should transition to complete state if account activated', () => {
|
||||
context.getState.returns({
|
||||
user: {
|
||||
@ -86,10 +100,28 @@ describe('ResendActivationState', () => {
|
||||
});
|
||||
|
||||
describe('#goBack', () => {
|
||||
it('should transition to resend-activation', () => {
|
||||
it('should transition to activation', () => {
|
||||
context.getState.returns({
|
||||
user: {
|
||||
isGuest: false
|
||||
}
|
||||
});
|
||||
|
||||
expectState(mock, ActivationState);
|
||||
|
||||
state.goBack(context);
|
||||
});
|
||||
|
||||
it('should transition to register if guest', () => {
|
||||
context.getState.returns({
|
||||
user: {
|
||||
isGuest: true
|
||||
}
|
||||
});
|
||||
|
||||
expectState(mock, RegisterState);
|
||||
|
||||
state.goBack(context);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user