Add tests for session.js

This commit is contained in:
Theresa Gresch 2019-08-09 09:38:02 +02:00
parent ccf6d341d1
commit ce395279c0

View file

@ -0,0 +1,30 @@
import assert from 'assert';
import Session from 'common/session';
describe('common/session', () => {
it('should construct session', () => {
const storage = window.localStorage;
const session = new Session(storage);
assert.equal(session.session_token, null);
});
it('should set and get token', () => {
const storage = window.localStorage;
const session = new Session(storage);
assert.equal(session.session_token, null);
session.setToken(123421);
assert.equal(session.session_token, 123421);
const result = session.getToken();
assert.equal(result, 123421);
});
it('should delete token', () => {
const storage = window.localStorage;
const session = new Session(storage);
assert.equal(session.session_token, null);
session.setToken(123421);
assert.equal(session.session_token, 123421);
session.deleteToken();
assert.equal(session.session_token, null);
});
});