18 lines
725 B
JavaScript
18 lines
725 B
JavaScript
// A modal `<dialog>` is `position: fixed` by default. Setting `position` on the
|
|
// `.ui-dialog` rule puts it in the page's flow, and focusing it on open then
|
|
// scrolls the page to the top. Run by `npm test`.
|
|
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import { test } from "node:test";
|
|
|
|
const css = readFileSync(
|
|
new URL("../src/ui/dialog/Dialog.css", import.meta.url),
|
|
"utf8",
|
|
);
|
|
|
|
test("the dialog rule leaves its position to the browser", () => {
|
|
const rule = css.match(/\.ui-dialog \{([^}]*)\}/);
|
|
assert.ok(rule, "the .ui-dialog rule exists");
|
|
const declarations = rule[1].replace(/\/\*[\s\S]*?\*\//g, "");
|
|
assert.doesNotMatch(declarations, /(^|[\s;])position\s*:/);
|
|
});
|