From 1f0a0870c932fd2511129c4356c9695068c78220 Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Tue, 5 Dec 2023 12:40:37 -0500 Subject: [PATCH] Session Id --- .../cookie-helper.spec.js | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/helpers/heritage-integration/cookie-helper.spec.js b/src/helpers/heritage-integration/cookie-helper.spec.js index c5cbc5bee..99a502559 100644 --- a/src/helpers/heritage-integration/cookie-helper.spec.js +++ b/src/helpers/heritage-integration/cookie-helper.spec.js @@ -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