-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
32 lines (27 loc) · 881 Bytes
/
Copy pathtest.js
File metadata and controls
32 lines (27 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import assert from "node:assert/strict";
import test from "node:test";
import { globalAttributes, elementAttributes } from "./index.js";
function assertAttributes(tag, attributes) {
assert.ok(
Array.isArray(attributes),
`Attributes in '${tag}' should be an array.`,
);
assert.ok(attributes.length > 0);
assert.equal(
new Set(attributes).size,
attributes.length,
`Attributes in '${tag}' should be unique.${JSON.stringify(attributes, undefined, 2)}`,
);
for (const attribute of attributes) {
assert.ok(/^\w+(?:-[\w]+)*$/.test(attribute), attribute);
}
}
test("Main", () => {
assertAttributes("*", globalAttributes);
for (const [tag, attributes] of Object.entries(elementAttributes)) {
assertAttributes(tag, attributes);
for (const attribute of attributes) {
assert.ok(!globalAttributes.includes(attribute));
}
}
});