diff --git a/clients/fides-js/__tests__/lib/consent-utils.test.ts b/clients/fides-js/__tests__/lib/consent-utils.test.ts index 3c25f0bb31..40c9226d15 100644 --- a/clients/fides-js/__tests__/lib/consent-utils.test.ts +++ b/clients/fides-js/__tests__/lib/consent-utils.test.ts @@ -1,4 +1,7 @@ -import {getWindowObjFromPath, isPrivacyExperience} from "../../src/lib/consent-utils"; +import { + getWindowObjFromPath, + isPrivacyExperience, +} from "../../src/lib/consent-utils"; const MOCK_EXPERIENCE = { id: "132345243", @@ -115,22 +118,40 @@ describe("getWindowObjFromPath", () => { }); const windowMock1 = { fides_overrides: { - hello: "something" - } - } + hello: "something", + }, + }; const windowMock2 = { overrides: { fides: { - hello: "something-else" - } - } - } + hello: "something-else", + }, + }, + }; it.each([ - { label: "path does not exist", path: ["window","nonexistent-path"], window: windowMock1, expected: undefined }, - { label: "path is one level deep", path: ["window","fides_overrides"], window: windowMock1, expected: {hello: "something"} }, - { label: "path is two levels deep", path: ["window","overrides","fides"], window: windowMock2, expected: {hello: "something-else"} }, - ])("returns $expected when path is $path and window is $window", ({ path, window, expected }) => { - windowSpy.mockImplementation(() => (window)); - expect(getWindowObjFromPath(path as any)).toStrictEqual(expected); - }); + { + label: "path does not exist", + path: ["window", "nonexistent-path"], + window: windowMock1, + expected: undefined, + }, + { + label: "path is one level deep", + path: ["window", "fides_overrides"], + window: windowMock1, + expected: { hello: "something" }, + }, + { + label: "path is two levels deep", + path: ["window", "overrides", "fides"], + window: windowMock2, + expected: { hello: "something-else" }, + }, + ])( + "returns $expected when path is $path and window is $window", + ({ path, window, expected }) => { + windowSpy.mockImplementation(() => window); + expect(getWindowObjFromPath(path as any)).toStrictEqual(expected); + } + ); }); diff --git a/clients/fides-js/src/lib/consent-utils.ts b/clients/fides-js/src/lib/consent-utils.ts index 7ed45cbaeb..be546ca5f5 100644 --- a/clients/fides-js/src/lib/consent-utils.ts +++ b/clients/fides-js/src/lib/consent-utils.ts @@ -4,7 +4,8 @@ import { ConsentMechanism, EmptyExperience, FidesOptions, - GpcStatus, OverrideOptions, + GpcStatus, + OverrideOptions, PrivacyExperience, PrivacyNotice, UserConsentPreference, @@ -258,7 +259,9 @@ export const shouldResurfaceConsent = ( /** * Get fides override options from a custom path */ -export const getWindowObjFromPath = (path: string[]): OverrideOptions | undefined => { +export const getWindowObjFromPath = ( + path: string[] +): OverrideOptions | undefined => { if (path[0] === "window") { path.shift(); }