Created
June 21, 2017 04:21
-
-
Save ajcrites/d72c9590eac3df9983cc30daafb70857 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// as a test function callback | |
it('removes username', inject([Storage], async storage => { | |
await storage.set('username', 'test user'); | |
await storage.clear(); | |
expect(await storage.get('username').toBeNull(); | |
})); |
This file contains hidden or 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
/* Promise chain Version */ | |
it('removes username', inject([Storage], storage => { | |
// return needs to be used here to return the Promise chain to | |
// `it` so it handles asynchronicity. Remember that `async` | |
// is already returning a Promise | |
return storage.set('username', 'test user') | |
.then(() => storage.clear()) | |
.then(() => storage.get('username')) | |
.then(username => expect(username).toBeNull()) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment