view client/tests/unit/session/session.spec.js @ 692:87ea9d267c2b

refac: transformation formula for diagram adjusted 1) the length of the segments of a polyline are now summed 2) each point has an x coordinate according to the length of the polyline up to this point 3) testdata were hand crafted and used as basis for plausibility checks
author Thomas Junk <thomas.junk@intevation.de>
date Thu, 20 Sep 2018 15:12:49 +0200
parents 79db27e3a999
children 0c5cbbafbd94
line wrap: on
line source

import {
  sessionStillActive,
  toMillisFromString
} from "../../../src/application/lib/session";

test("No session counts as expired session", () => {
  expect(sessionStillActive(null)).toBe(false);
});

test("Session expired", () => {
  const expired = Date.now() - 60000;
  expect(sessionStillActive(expired)).toBe(false);
});

test("Session alive", () => {
  const active = Date.now() + 60000;
  expect(sessionStillActive(active)).toBe(true);
});

test("Session alive with string", () => {
  const active = "" + Date.now() / 1000 + 60000;
  expect(sessionStillActive(toMillisFromString(active))).toBe(true);
});

test("Session expired with string", () => {
  const expired = "" + Date.now() / 1000 - 60000;
  expect(sessionStillActive(toMillisFromString(expired))).toBe(false);
});