Files
speaking-practice/tests/auth-ui-helpers.test.mjs
T
TTlaji 0c12ce5f33
Deploy Speaking Practice / deploy (push) Successful in 26s
feat: enforce single active user session
2026-06-15 14:40:33 +08:00

12 lines
539 B
JavaScript

import assert from "node:assert/strict";
import authHelpers from "../auth.js";
const { getLoginUrlForPath, isUnauthorizedStatus, shouldShowAdminEntry } = authHelpers;
assert.equal(getLoginUrlForPath("/study.html?video=2"), "./login.html?next=%2Fstudy.html%3Fvideo%3D2");
assert.equal(isUnauthorizedStatus(401), true);
assert.equal(isUnauthorizedStatus(403), false);
assert.equal(shouldShowAdminEntry({ role: "admin" }), true);
assert.equal(shouldShowAdminEntry({ role: "user" }), false);
assert.equal(shouldShowAdminEntry(null), false);