Add tests for session.js
This commit is contained in:
parent
ccf6d341d1
commit
ce395279c0
1 changed files with 30 additions and 0 deletions
30
frontend/tests/unit/common/session_test.js
Normal file
30
frontend/tests/unit/common/session_test.js
Normal 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);
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue