-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
test.js
47 lines (40 loc) · 1.21 KB
/
test.js
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import assert from 'node:assert/strict'
import test from 'node:test'
import {htmlElementAttributes} from './index.js'
const own = {}.hasOwnProperty
test('htmlElementAttributes', function () {
assert.equal(typeof htmlElementAttributes, 'object', 'should be an `object`')
/** @type {string} */
let key
for (key in htmlElementAttributes) {
if (own.call(htmlElementAttributes, key)) {
assert.ok(Array.isArray(htmlElementAttributes[key]), key)
}
}
for (key in htmlElementAttributes) {
if (own.call(htmlElementAttributes, key)) {
const properties = htmlElementAttributes[key]
let index = -1
while (++index < properties.length) {
const property = properties[index]
const label = property + ' in ' + key
assert.strictEqual(
typeof property,
'string',
label + ' should be string'
)
assert.strictEqual(
property,
property.toLowerCase(),
label + ' should be lower-case'
)
assert.strictEqual(
property,
property.trim(),
label + ' should be trimmed'
)
assert.ok(/^[a-z-]+$/.test(property), label + ' should be `a-z-`')
}
}
}
})