mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-11-15 04:35:57 +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 AbstractState from './AbstractState';
|
||||||
import CompleteState from './CompleteState';
|
import CompleteState from './CompleteState';
|
||||||
|
import ResendActivationState from './ResendActivationState';
|
||||||
|
|
||||||
export default class RegisterState extends AbstractState {
|
export default class RegisterState extends AbstractState {
|
||||||
enter(context) {
|
enter(context) {
|
||||||
@ -18,5 +19,6 @@ export default class RegisterState extends AbstractState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
reject(context) {
|
reject(context) {
|
||||||
|
context.setState(new ResendActivationState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
import AbstractState from './AbstractState';
|
import AbstractState from './AbstractState';
|
||||||
import CompleteState from './CompleteState';
|
import CompleteState from './CompleteState';
|
||||||
import ActivationState from './ActivationState';
|
import ActivationState from './ActivationState';
|
||||||
|
import RegisterState from './RegisterState';
|
||||||
|
|
||||||
export default class ResendActivationState extends AbstractState {
|
export default class ResendActivationState extends AbstractState {
|
||||||
enter(context) {
|
enter(context) {
|
||||||
const {user} = context.getState();
|
const {user} = context.getState();
|
||||||
|
|
||||||
if (user.isActive) {
|
if (user.isActive && !user.isGuest) {
|
||||||
context.setState(new CompleteState());
|
context.setState(new CompleteState());
|
||||||
} else {
|
} else {
|
||||||
context.navigate('/repeat-message');
|
context.navigate('/resend-activation');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,6 +20,12 @@ export default class ResendActivationState extends AbstractState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
goBack(context) {
|
goBack(context) {
|
||||||
|
const {user} = context.getState();
|
||||||
|
|
||||||
|
if (user.isGuest) {
|
||||||
|
context.setState(new RegisterState());
|
||||||
|
} else {
|
||||||
context.setState(new ActivationState());
|
context.setState(new ActivationState());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import RegisterState from 'services/authFlow/RegisterState';
|
import RegisterState from 'services/authFlow/RegisterState';
|
||||||
import CompleteState from 'services/authFlow/CompleteState';
|
import CompleteState from 'services/authFlow/CompleteState';
|
||||||
|
import ResendActivationState from 'services/authFlow/ResendActivationState';
|
||||||
|
|
||||||
import { bootstrap, expectState, expectNavigate, expectRun } from './helpers';
|
import { bootstrap, expectState, expectNavigate, expectRun } from './helpers';
|
||||||
|
|
||||||
@ -78,4 +79,12 @@ describe('RegisterState', () => {
|
|||||||
return promise.catch(mock.verify.bind(mock));
|
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 ResendActivationState from 'services/authFlow/ResendActivationState';
|
||||||
import CompleteState from 'services/authFlow/CompleteState';
|
import CompleteState from 'services/authFlow/CompleteState';
|
||||||
import ActivationState from 'services/authFlow/ActivationState';
|
import ActivationState from 'services/authFlow/ActivationState';
|
||||||
|
import RegisterState from 'services/authFlow/RegisterState';
|
||||||
|
|
||||||
import { bootstrap, expectState, expectNavigate, expectRun } from './helpers';
|
import { bootstrap, expectState, expectNavigate, expectRun } from './helpers';
|
||||||
|
|
||||||
@ -35,6 +36,19 @@ describe('ResendActivationState', () => {
|
|||||||
state.enter(context);
|
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', () => {
|
it('should transition to complete state if account activated', () => {
|
||||||
context.getState.returns({
|
context.getState.returns({
|
||||||
user: {
|
user: {
|
||||||
@ -86,10 +100,28 @@ describe('ResendActivationState', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('#goBack', () => {
|
describe('#goBack', () => {
|
||||||
it('should transition to resend-activation', () => {
|
it('should transition to activation', () => {
|
||||||
|
context.getState.returns({
|
||||||
|
user: {
|
||||||
|
isGuest: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
expectState(mock, ActivationState);
|
expectState(mock, ActivationState);
|
||||||
|
|
||||||
state.goBack(context);
|
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