diff --git a/frontend/tests/unit/common/session_test.js b/frontend/tests/unit/common/session_test.js new file mode 100644 index 000000000..ff22a2072 --- /dev/null +++ b/frontend/tests/unit/common/session_test.js @@ -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); + }); +}); \ No newline at end of file