#48: call authentication.logout for each revoked account

This commit is contained in:
SleepWalker
2016-11-15 07:55:15 +02:00
parent 9e7d5b8338
commit 5142d65b39
7 changed files with 214 additions and 73 deletions

View File

@@ -1,5 +1,6 @@
import expect from 'unexpected';
import request from 'services/request';
import authentication from 'services/api/authentication';
import accounts from 'services/api/accounts';
@@ -88,4 +89,38 @@ describe('authentication api', () => {
});
});
});
describe('#logout', () => {
beforeEach(() => {
sinon.stub(request, 'post').named('request.post');
});
afterEach(() => {
request.post.restore();
});
it('should request logout api', () => {
authentication.logout();
expect(request.post, 'to have a call satisfying', [
'/api/authentication/logout', {}, {}
]);
});
it('returns a promise', () => {
request.post.returns(Promise.resolve());
return expect(authentication.logout(), 'to be fulfilled');
});
it('overrides token if provided', () => {
const token = 'foo';
authentication.logout({token});
expect(request.post, 'to have a call satisfying', [
'/api/authentication/logout', {}, {token}
]);
});
});
});