Skip to content

Commit

Permalink
fix: don't account for empty attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
jbergstroem committed Oct 9, 2024
1 parent c99879e commit 21dc4d4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/detector.impressions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,19 @@ test("check impresssions", async () => {
},
]);
});

test("don\'t consider empty attributes", async () => {
window.TS = {
token: "token",
};
const events: any[] = [];
window.addEventListener("topsort", (e) => {
events.push((e as any).detail);
});
document.body.innerHTML = `
<div data-ts-resolved-bid=""></div>
`;
await import("./detector");

expect(events).toMatchObject([]);

Check failure on line 51 in src/detector.impressions.test.ts

View workflow job for this annotation

GitHub Actions / test

src/detector.impressions.test.ts > don't consider empty attributes

AssertionError: expected [ { type: 'Impression', …(7) } ] to match object [] - Expected + Received - Array [] + Array [ + Object { + "additionalProduct": undefined, + "bid": "", + "id": "0.5131017924514547", + "page": "/", + "product": undefined, + "t": 1728494430587, + "type": "Impression", + "uid": "0.36531875738500563", + }, + ] ❯ src/detector.impressions.test.ts:51:18
});

0 comments on commit 21dc4d4

Please sign in to comment.