-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathpageview-query.test.js
More file actions
40 lines (34 loc) · 1.15 KB
/
pageview-query.test.js
File metadata and controls
40 lines (34 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const { expect } = require("chai");
const { createDOM } = require("./helpers/dom");
describe("pageview query", function () {
it("sends query params from manual path", function (done) {
const dom = createDOM({
settings: { autoCollect: false, allowParams: "foo" },
});
dom.window.sa_pageview("/manual?foo=bar");
setTimeout(() => {
const req = dom.sent.find(
(r) => r.type === "image" && /path=%2Fmanual/.test(r.url)
);
expect(req, "pageview request").to.exist;
const url = new URL(req.url);
expect(url.searchParams.get("query")).to.equal("foo=bar");
done();
}, 10);
});
it("matches allowed params case insensitively", function (done) {
const dom = createDOM({
settings: { autoCollect: false, allowParams: "foo" },
});
dom.window.sa_pageview("/manual?FOO=bar");
setTimeout(() => {
const req = dom.sent.find(
(r) => r.type === "image" && /path=%2Fmanual/.test(r.url)
);
expect(req, "pageview request").to.exist;
const url = new URL(req.url);
expect(url.searchParams.get("query")).to.equal("FOO=bar");
done();
}, 10);
});
});