diff --git a/src/helpers/heritage-integration/cookie-helper.spec.js b/src/helpers/heritage-integration/cookie-helper.spec.js index 349b2206a..c5cbc5bee 100644 --- a/src/helpers/heritage-integration/cookie-helper.spec.js +++ b/src/helpers/heritage-integration/cookie-helper.spec.js @@ -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", () => {