Session Id

This commit is contained in:
Chloe Herd 2023-12-05 12:40:37 -05:00
parent 736aee68e9
commit 1f0a0870c9

View file

@ -8,6 +8,7 @@ import {
getUserIdValue,
regenerateUserId,
setSessionKeyIfUnset,
setSessionIdIfUnset,
} from "@/helpers/heritage-integration/cookie-helper.js";
import { cookieNames } from "@/constants/cookie-names";
import { removeAllTestCookies, setupCookies, setupCrypto } from "@/helpers/unit-test-helper";
@ -285,6 +286,56 @@ describe("cookies", () => {
});
});
describe("Session Id", () => {
describe("getSessionIdValue", () => {
test("Should return session id", () => {
// Arrange
setupCookies({});
// Act
const result = getSessionIdValue();
//Assert
expect(result).toBe("cba0c3d1-3c1b-4305-bb56-31aa50f58e27");
});
test("Should return 0s if unset", () => {
// Arrange
// Act
const result = getSessionIdValue();
//Assert
expect(result).toBe("00000000-0000-0000-0000-000000000000");
});
});
describe("setSessionIdIfUnset", () => {
test("Should set the cookie if not previously set", () => {
// Arrange
// Act
setSessionIdIfUnset("f01f463a-a02c-4d1a-8aaf-6ca920ae5f02");
const result = getSessionIdValue();
// Assert
expect(result).toBe("f01f463a-a02c-4d1a-8aaf-6ca920ae5f02");
});
test("Should not set the cookie if previously set", () => {
// Arrange
setupCookies({});
// Act
setSessionIdIfUnset("f01f463a-a02c-4d1a-8aaf-6ca920ae5f02");
const result = getSessionIdValue();
// Assert
expect(result).toBe("cba0c3d1-3c1b-4305-bb56-31aa50f58e27");
});
});
});
describe("getSessionIdValue", () => {
test("getSessionIdValue, should return GUID", () => {
// Arrange