view src/style.test.ts @ 150:3ce355e4f388 default tip

bye jest; hi vitest. new working test for styles.ts
author drewp@bigasterisk.com
date Mon, 08 May 2023 17:27:44 -0700
parents
children
line wrap: on
line source

import { describe, expect, it } from "vitest";
import { addFontToRootPage } from "./style";

describe("addFontToRootPage", () => {
  it("adds a style block", () => {
    addFontToRootPage();
    const el = document.head.children[0] as HTMLElement;
    expect(el.innerText).toContain("@font-face");
  });
  it("is idempotent", () => {
    addFontToRootPage();
    addFontToRootPage();
    expect(document.head.children.length).toBe(1);
  });
});