Session Key
This commit is contained in:
parent
aa59d955cb
commit
736aee68e9
1 changed files with 47 additions and 7 deletions
|
|
@ -7,6 +7,7 @@ import {
|
||||||
regenerateDeviceId,
|
regenerateDeviceId,
|
||||||
getUserIdValue,
|
getUserIdValue,
|
||||||
regenerateUserId,
|
regenerateUserId,
|
||||||
|
setSessionKeyIfUnset,
|
||||||
} from "@/helpers/heritage-integration/cookie-helper.js";
|
} from "@/helpers/heritage-integration/cookie-helper.js";
|
||||||
import { cookieNames } from "@/constants/cookie-names";
|
import { cookieNames } from "@/constants/cookie-names";
|
||||||
import { removeAllTestCookies, setupCookies, setupCrypto } from "@/helpers/unit-test-helper";
|
import { removeAllTestCookies, setupCookies, setupCrypto } from "@/helpers/unit-test-helper";
|
||||||
|
|
@ -234,7 +235,9 @@ describe("cookies", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("getSessionKeyValue, should return session key int", () => {
|
describe("Session Key", () => {
|
||||||
|
describe("getSessionKeyValue", () => {
|
||||||
|
test("Should return session key int", () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
setupCookies({});
|
setupCookies({});
|
||||||
|
|
||||||
|
|
@ -245,6 +248,43 @@ describe("cookies", () => {
|
||||||
expect(result).toBe("12345");
|
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", () => {
|
describe("getSessionIdValue", () => {
|
||||||
test("getSessionIdValue, should return GUID", () => {
|
test("getSessionIdValue, should return GUID", () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue