Files
sanderling/pkg/spec/test/selector-keys.test.ts
T
pj 269574706d feat(spec): reject an unknown object-selector key in the web runtime
Same rule and the same message as the native side: a key no element can
carry throws instead of matching nothing. The accepted list is one list,
committed as a fixture both suites assert, so a spec cannot be accepted
by one runtime and rejected by the other.
2026-08-13 00:38:40 +05:30

22 lines
926 B
TypeScript

import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
import { test } from "node:test";
import { __testing__ } from "../src/web-runtime.ts";
const { SELECTOR_KEYS } = __testing__;
const goldenPath = fileURLToPath(new URL("./fixtures/selector-keys.json", import.meta.url));
const golden: string[] = JSON.parse(readFileSync(goldenPath, "utf8"));
// Both runtimes reject an object-selector key they do not know, so the two key
// lists have to be one list. Were they to drift, a spec would be accepted by
// the runtime that lists the key and fail the run on the one that does not, and
// the difference would only show on the platform nobody ran first.
// internal/hierarchy/selector_keys_test.go asserts the SAME file from the
// native side.
test("the web key list is the cross-runtime list", () => {
assert.deepEqual([...SELECTOR_KEYS], golden);
});