Skip to content

Instantly share code, notes, and snippets.

@ajcrites
Created June 21, 2017 04:21
Show Gist options
  • Save ajcrites/d72c9590eac3df9983cc30daafb70857 to your computer and use it in GitHub Desktop.
Save ajcrites/d72c9590eac3df9983cc30daafb70857 to your computer and use it in GitHub Desktop.
// 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();
}));
/* 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