Session Key

This commit is contained in:
Chloe Herd 2023-12-05 11:46:31 -05:00
parent aa59d955cb
commit 736aee68e9

View file

@ -7,6 +7,7 @@ import {
regenerateDeviceId,
getUserIdValue,
regenerateUserId,
setSessionKeyIfUnset,
} from "@/helpers/heritage-integration/cookie-helper.js";
import { cookieNames } from "@/constants/cookie-names";
import { removeAllTestCookies, setupCookies, setupCrypto } from "@/helpers/unit-test-helper";
@ -234,15 +235,54 @@ describe("cookies", () => {
});
});
test("getSessionKeyValue, should return session key int", () => {
// Arrange
setupCookies({});
describe("Session Key", () => {
describe("getSessionKeyValue", () => {
test("Should return session key int", () => {
// Arrange
setupCookies({});
// Act
const result = getSessionKeyValue();
// Act
const result = getSessionKeyValue();
//Assert
expect(result).toBe("12345");
//Assert
expect(result).toBe("12345");
});
test("Should return 0 if unset", () => {
// Arrange
// Act
const result = getSessionKeyValue();
//Assert
expect(result).toBe(0);
});
});
describe("setSessionKeyIfUnset", () => {
test("Should set the cookie if not previously set", () => {
// Arrange
// Act
setSessionKeyIfUnset("54321");
const result = getSessionKeyValue();
// Assert
expect(result).toBe("54321");
});
test("Should not set the cookie if previously set", () => {
// Arrange
setupCookies({});
// Act
setSessionKeyIfUnset("54321");
const result = getSessionKeyValue();
// Assert
expect(result).toBe("12345");
});
});
});
describe("getSessionIdValue", () => {