32 lines
1.2 KiB
TypeScript
32 lines
1.2 KiB
TypeScript
import { readFile } from "node:fs/promises";
|
|
import path from "node:path";
|
|
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
async function read(rel: string) {
|
|
return await readFile(path.join(process.cwd(), rel), "utf8");
|
|
}
|
|
|
|
describe("umami event attributes", () => {
|
|
it("instruments nav links using data-umami-event", async () => {
|
|
const src = await read("src/layouts/BaseLayout.astro");
|
|
expect(src).toContain('data-umami-event="click"');
|
|
expect(src).toContain('data-umami-event-target_id="nav.videos"');
|
|
expect(src).toContain('data-umami-event-placement="nav"');
|
|
});
|
|
|
|
it("instruments CTAs using data-umami-event and unique target_id", async () => {
|
|
const src = await read("src/components/CtaLink.astro");
|
|
expect(src).toContain('data-umami-event="cta_click"');
|
|
expect(src).toContain("data-umami-event-target_id");
|
|
expect(src).toContain("data-umami-event-placement");
|
|
});
|
|
|
|
it("instruments content cards using outbound_click", async () => {
|
|
const src = await read("src/components/ContentCard.astro");
|
|
expect(src).toContain('"data-umami-event": "outbound_click"');
|
|
expect(src).toContain("data-umami-event-target_id");
|
|
expect(src).toContain("data-umami-event-domain");
|
|
});
|
|
});
|