Убрал повторный запрос на complete, когда acceptRequired

This commit is contained in:
SleepWalker
2016-04-14 22:54:35 +03:00
parent c7cce17f11
commit a2293b570e
4 changed files with 94 additions and 5 deletions

View File

@@ -112,6 +112,25 @@ describe('CompleteState', () => {
state.enter(context);
});
it('should transition to permissions state if acceptRequired', () => {
context.getState.returns({
user: {
isActive: true,
isGuest: false
},
auth: {
oauth: {
clientId: 'ely.by',
acceptRequired: true
}
}
});
expectState(mock, PermissionsState);
state.enter(context);
});
});
describe('oAuthComplete', () => {
@@ -236,7 +255,7 @@ describe('CompleteState', () => {
it('should transition to permissions state if rejected with acceptRequired', () => {
return testOAuth('reject', {acceptRequired: true}, PermissionsState);
});
})
});
describe('permissions accept', () => {
it('should set flags, when user accepted permissions', () => {
@@ -301,5 +320,61 @@ describe('CompleteState', () => {
state.enter(context);
});
it('should run oAuthComplete passing accept: true, while acceptRequired: true', () => {
// acceptRequired may block user accept/decline actions, so we need
// to check that they are accessible
const expected = {accept: true};
state = new CompleteState(expected);
context.getState.returns({
user: {
isActive: true,
isGuest: false
},
auth: {
oauth: {
clientId: 'ely.by',
acceptRequired: true
}
}
});
expectRun(
mock,
'oAuthComplete',
sinon.match(expected)
).returns({then() {}});
state.enter(context);
});
it('should run oAuthComplete passing accept: false, while acceptRequired: true', () => {
// acceptRequired may block user accept/decline actions, so we need
// to check that they are accessible
const expected = {accept: false};
state = new CompleteState(expected);
context.getState.returns({
user: {
isActive: true,
isGuest: false
},
auth: {
oauth: {
clientId: 'ely.by',
acceptRequired: true
}
}
});
expectRun(
mock,
'oAuthComplete',
sinon.match(expected)
).returns({then() {}});
state.enter(context);
});
});
});