From ce395279c05a9140984cb75b2159343665c6b294 Mon Sep 17 00:00:00 2001 From: Theresa Gresch Date: Fri, 9 Aug 2019 09:38:02 +0200 Subject: [PATCH] Add tests for session.js --- frontend/tests/unit/common/session_test.js | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 frontend/tests/unit/common/session_test.js 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