CSR-1632
unit test case
This commit is contained in:
parent
8322d44173
commit
a2b3e5bb31
2 changed files with 29 additions and 1 deletions
|
|
@ -11,9 +11,15 @@ import {
|
|||
setSessionIdIfUnset,
|
||||
isCookieSet,
|
||||
refreshCookieExpiration,
|
||||
getAffiliateCookies,
|
||||
} from "@/helpers/heritage-integration/cookie-helper.js";
|
||||
import { cookieNames } from "@/constants/cookie-names";
|
||||
import { removeAllTestCookies, setupCookies, setupCrypto } from "@/helpers/unit-test-helper";
|
||||
import {
|
||||
removeAllTestCookies,
|
||||
setupCookies,
|
||||
setupCrypto,
|
||||
setupAffiliateCookies,
|
||||
} from "@/helpers/unit-test-helper";
|
||||
import { deleteFunnelCookie } from "./cookie-helper";
|
||||
|
||||
const randomUUID = "68d89736-c277-46f1-8fee-c3dacdb23c08";
|
||||
|
|
@ -431,3 +437,21 @@ describe("cookies", () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
describe("getAffiliateCookies", () => {
|
||||
it("should return an empty array if no affiliate cookies are found", () => {
|
||||
setupAffiliateCookies({});
|
||||
expect(getAffiliateCookies()).toEqual([]);
|
||||
});
|
||||
|
||||
it("should return an array of affiliate cookies when they are present", () => {
|
||||
setupAffiliateCookies({
|
||||
CookieName: "affiliate_cookie1_Track",
|
||||
CookieValue: "value_of_affiliate_cookie1",
|
||||
});
|
||||
|
||||
const expectedCookies = [
|
||||
{ CookieName: "affiliate_cookie1_Track", CookieValue: "value_of_affiliate_cookie1" },
|
||||
];
|
||||
expect(getAffiliateCookies()).toEqual(expectedCookies);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -139,6 +139,10 @@ export function setupCookies({ funnelCookieValue = "", includeHeritageCookie = t
|
|||
});
|
||||
}
|
||||
|
||||
export function setupAffiliateCookies(cookie) {
|
||||
setCookieProperties({ [cookie.CookieName]: cookie.CookieValue }, { isSecure: false });
|
||||
}
|
||||
|
||||
export function setupCrypto(mockValue) {
|
||||
global.crypto = {
|
||||
randomUUID: jest.fn(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue