Skip to content

Commit de720ae

Browse files
committed
Remove location changing from advertising helper specs
1 parent 79ba414 commit de720ae

File tree

2 files changed

+19
-38
lines changed

2 files changed

+19
-38
lines changed

packages/core/test/unit/helpers/utils/location.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

packages/core/test/unit/specs/components/Advertising/utils/helpers.spec.js

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
DISPLAY_CLICK_COOKIE_KEY_EXPIRES,
2828
AD_CONVERSION_VIEW_EVENT_TYPE,
2929
} from "../../../../../../src/components/Advertising/constants/index.js";
30-
import { withTemporaryUrl } from "../../../../helpers/utils/location.js";
30+
import { queryString } from "../../../../../../src/utils/index.js";
3131

3232
describe("Advertising::helpers", () => {
3333
let mockEvent;
@@ -60,44 +60,37 @@ describe("Advertising::helpers", () => {
6060

6161
describe("getUrlParams", () => {
6262
it("should return URL parameters when present", () => {
63-
return withTemporaryUrl(({ currentHref, applyUrl }) => {
64-
const url = new URL(currentHref);
65-
url.search = "?s_kwcid=test_kwcid&ef_id=test_efid";
66-
applyUrl(url);
63+
vi.spyOn(queryString, "parse").mockReturnValue({
64+
s_kwcid: "test_kwcid",
65+
ef_id: "test_efid",
66+
});
6767

68-
const result = getUrlParams();
68+
const result = getUrlParams();
6969

70-
expect(result).toEqual({
71-
skwcid: "test_kwcid",
72-
efid: "test_efid",
73-
});
70+
expect(result).toEqual({
71+
skwcid: "test_kwcid",
72+
efid: "test_efid",
7473
});
7574
});
7675

7776
it("should return undefined values when parameters are not present", () => {
78-
return withTemporaryUrl(({ currentHref, applyUrl }) => {
79-
const url = new URL(currentHref);
80-
url.search = "?foo=bar";
81-
applyUrl(url);
77+
vi.spyOn(queryString, "parse").mockReturnValue({
78+
foo: "bar",
79+
});
8280

83-
const result = getUrlParams();
81+
const result = getUrlParams();
8482

85-
expect(result.skwcid).toBeUndefined();
86-
expect(result.efid).toBeUndefined();
87-
});
83+
expect(result.skwcid).toBeUndefined();
84+
expect(result.efid).toBeUndefined();
8885
});
8986

9087
it("should handle empty search string", () => {
91-
return withTemporaryUrl(({ currentHref, applyUrl }) => {
92-
const url = new URL(currentHref);
93-
url.search = "";
94-
applyUrl(url);
88+
vi.spyOn(queryString, "parse").mockReturnValue({});
9589

96-
const result = getUrlParams();
90+
const result = getUrlParams();
9791

98-
expect(result.skwcid).toBeUndefined();
99-
expect(result.efid).toBeUndefined();
100-
});
92+
expect(result.skwcid).toBeUndefined();
93+
expect(result.efid).toBeUndefined();
10194
});
10295
});
10396

0 commit comments

Comments
 (0)