-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: prevent signIn if session present
* test: no sign in while signed in * test: prevent signIn if session present * test: remove redundant test * test: more descriptive test name * test: typo * test: fix typo
- Loading branch information
Showing
2 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ test('sign in', function (t) { | |
account.signIn(options) | ||
|
||
.then(function (signInResult) { | ||
t.pass('signes in') | ||
t.pass('signs in') | ||
t.is(signInResult.username, '[email protected]') | ||
|
||
var storeAccount = store.getObject('account') | ||
|
@@ -62,7 +62,7 @@ test('sign in', function (t) { | |
}) | ||
|
||
.then(function (signOutResult) { | ||
t.pass('signes out') | ||
t.pass('signs out') | ||
|
||
t.is(signOutResult.username, '[email protected]') | ||
|
||
|
@@ -85,3 +85,34 @@ test('sign in', function (t) { | |
|
||
.catch(t.error) | ||
}) | ||
|
||
test('prevent sign-in when already signed in', function (t) { | ||
store.clear() | ||
t.plan(1) | ||
|
||
var account = new Account({ | ||
url: baseURL, | ||
id: 'abc4567' | ||
}) | ||
|
||
nock(baseURL) | ||
.put('/session') | ||
.reply(201, signInResponse) | ||
|
||
account.signIn(options) | ||
|
||
.then(function (signInResult) { | ||
return account.signIn({ | ||
username: '[email protected]', | ||
password: 'secret' | ||
}) | ||
}) | ||
|
||
.then(function () { | ||
t.fail('Sign in must fail when already signed in') | ||
}) | ||
|
||
.catch(function (error) { | ||
t.is(error.message, 'You must sign out before signing in') | ||
}) | ||
}) |