Mercurial > gemma
diff client/tests/unit/session/session.spec.js @ 165:4bf2173748f3
refactor: extracted the string to milisecondconversion
Extracted the conversion of session data to string conversion
to Method. SRP.
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Fri, 06 Jul 2018 11:04:52 +0200 |
parents | 7c40e9f28f94 |
children | 79db27e3a999 |
line wrap: on
line diff
--- a/client/tests/unit/session/session.spec.js Fri Jul 06 10:51:19 2018 +0200 +++ b/client/tests/unit/session/session.spec.js Fri Jul 06 11:04:52 2018 +0200 @@ -1,11 +1,14 @@ -import { sessionStillActive } from "../../../src/lib/session"; +import { + sessionStillActive, + toMillisFromString +} from "../../../src/lib/session"; test("No session counts as expired session", () => { expect(sessionStillActive(null)).toBe(false); }); test("Session expired", () => { - const expired = Date.now() - 6000; + const expired = Date.now() - 60000; expect(sessionStillActive(expired)).toBe(false); }); @@ -15,11 +18,11 @@ }); test("Session alive with string", () => { - const active = "" + Date.now() + 60000; - expect(sessionStillActive(active)).toBe(true); + const active = "" + Date.now() / 1000 + 60000; + expect(sessionStillActive(toMillisFromString(active))).toBe(true); }); test("Session expired with string", () => { - const expired = "" + Date.now() - 60000; - expect(sessionStillActive(expired)).toBe(false); + const expired = "" + Date.now() / 1000 - 60000; + expect(sessionStillActive(toMillisFromString(expired))).toBe(false); });