2022-09-22 22:01:57 +02:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const {strict: assert} = require("assert");
|
|
|
|
|
2023-02-22 23:04:10 +01:00
|
|
|
const {zrequire} = require("./lib/namespace");
|
2023-12-14 23:51:33 +01:00
|
|
|
const {run_test, noop} = require("./lib/test");
|
|
|
|
|
2022-09-22 22:01:57 +02:00
|
|
|
// override file-level function call in reload.js
|
2023-12-14 23:51:33 +01:00
|
|
|
window.addEventListener = noop;
|
2022-09-22 22:01:57 +02:00
|
|
|
const reload = zrequire("reload");
|
|
|
|
|
|
|
|
run_test("old_metadata_string_is_stale", () => {
|
|
|
|
assert.ok(reload.is_stale_refresh_token("1663886962834", "1663883954033"), true);
|
|
|
|
});
|
|
|
|
|
|
|
|
run_test("recent_token_is_not_stale ", () => {
|
|
|
|
assert.ok(
|
|
|
|
!reload.is_stale_refresh_token(
|
|
|
|
{
|
|
|
|
url: "#reload:234234235234",
|
|
|
|
timestamp: Date.parse("21 Jan 2022 00:00:00 GMT"),
|
|
|
|
},
|
|
|
|
Date.parse("23 Jan 2022 00:00:00 GMT"),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
run_test("old_token_is_stale ", () => {
|
|
|
|
assert.ok(
|
|
|
|
reload.is_stale_refresh_token(
|
|
|
|
{
|
|
|
|
url: "#reload:234234235234",
|
|
|
|
timestamp: Date.parse("13 Jan 2022 00:00:00 GMT"),
|
|
|
|
},
|
|
|
|
Date.parse("23 Jan 2022 00:00:00 GMT"),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
});
|