|
1 | 1 | import assert from 'node:assert/strict'
|
2 | 2 | import test from 'node:test'
|
3 | 3 | import {labelable} from './index.js'
|
4 |
| -import * as mod from './index.js' |
5 | 4 |
|
6 |
| -test('labelable', () => { |
7 |
| - assert.deepEqual( |
8 |
| - Object.keys(mod).sort(), |
9 |
| - ['labelable'], |
10 |
| - 'should expose the public api' |
11 |
| - ) |
| 5 | +test('labelable', async function (t) { |
| 6 | + await t.test('should expose the public api', async function () { |
| 7 | + assert.deepEqual(Object.keys(await import('./index.js')).sort(), [ |
| 8 | + 'labelable' |
| 9 | + ]) |
| 10 | + }) |
12 | 11 |
|
13 |
| - // @ts-expect-error: runtime. |
14 |
| - assert.equal(labelable(), false, 'should return `false` without node') |
| 12 | + await t.test('should return `false` without node', async function () { |
| 13 | + // @ts-expect-error: check that the runtime supports a missing node. |
| 14 | + assert.equal(labelable(), false) |
| 15 | + }) |
15 | 16 |
|
16 |
| - assert.equal( |
17 |
| - labelable({type: 'text', value: 'Alpha'}), |
18 |
| - false, |
19 |
| - 'should return `false` without element' |
20 |
| - ) |
| 17 | + await t.test('should return `false` without element', async function () { |
| 18 | + assert.equal(labelable({type: 'text', value: 'Alpha'}), false) |
| 19 | + }) |
21 | 20 |
|
22 |
| - assert.equal( |
23 |
| - labelable({type: 'element', tagName: 'div', properties: {}, children: []}), |
24 |
| - false, |
25 |
| - 'should return `false` for non-labelable elements' |
| 21 | + await t.test( |
| 22 | + 'should return `false` for non-labelable elements', |
| 23 | + async function () { |
| 24 | + assert.equal( |
| 25 | + labelable({ |
| 26 | + type: 'element', |
| 27 | + tagName: 'div', |
| 28 | + properties: {}, |
| 29 | + children: [] |
| 30 | + }), |
| 31 | + false |
| 32 | + ) |
| 33 | + } |
26 | 34 | )
|
27 | 35 |
|
28 |
| - assert.equal( |
29 |
| - labelable({ |
30 |
| - type: 'element', |
31 |
| - tagName: 'input', |
32 |
| - properties: {}, |
33 |
| - children: [] |
34 |
| - }), |
35 |
| - true, |
36 |
| - 'should return `true` for `input` elements' |
37 |
| - ) |
| 36 | + await t.test('should return `true` for `input` elements', async function () { |
| 37 | + assert.equal( |
| 38 | + labelable({ |
| 39 | + type: 'element', |
| 40 | + tagName: 'input', |
| 41 | + properties: {}, |
| 42 | + children: [] |
| 43 | + }), |
| 44 | + true |
| 45 | + ) |
| 46 | + }) |
38 | 47 |
|
39 |
| - assert.equal( |
40 |
| - labelable({ |
41 |
| - type: 'element', |
42 |
| - tagName: 'input', |
43 |
| - properties: {type: 'hidden'}, |
44 |
| - children: [] |
45 |
| - }), |
46 |
| - false, |
47 |
| - 'should return `false` for `input[type=hidden]` elements' |
| 48 | + await t.test( |
| 49 | + 'should return `false` for `input[type=hidden]` elements', |
| 50 | + async function () { |
| 51 | + assert.equal( |
| 52 | + labelable({ |
| 53 | + type: 'element', |
| 54 | + tagName: 'input', |
| 55 | + properties: {type: 'hidden'}, |
| 56 | + children: [] |
| 57 | + }), |
| 58 | + false |
| 59 | + ) |
| 60 | + } |
48 | 61 | )
|
49 | 62 |
|
50 |
| - assert.equal( |
51 |
| - labelable({ |
52 |
| - type: 'element', |
53 |
| - tagName: 'button', |
54 |
| - properties: {}, |
55 |
| - children: [] |
56 |
| - }), |
57 |
| - true, |
58 |
| - 'should return `true` for `button` elements' |
59 |
| - ) |
| 63 | + await t.test('should return `true` for `button` elements', async function () { |
| 64 | + assert.equal( |
| 65 | + labelable({ |
| 66 | + type: 'element', |
| 67 | + tagName: 'button', |
| 68 | + properties: {}, |
| 69 | + children: [] |
| 70 | + }), |
| 71 | + true |
| 72 | + ) |
| 73 | + }) |
60 | 74 |
|
61 |
| - assert.equal( |
62 |
| - labelable({ |
63 |
| - type: 'element', |
64 |
| - tagName: 'keygen', |
65 |
| - properties: {}, |
66 |
| - children: [] |
67 |
| - }), |
68 |
| - true, |
69 |
| - 'should return `true` for `keygen` elements' |
70 |
| - ) |
| 75 | + await t.test('should return `true` for `keygen` elements', async function () { |
| 76 | + assert.equal( |
| 77 | + labelable({ |
| 78 | + type: 'element', |
| 79 | + tagName: 'keygen', |
| 80 | + properties: {}, |
| 81 | + children: [] |
| 82 | + }), |
| 83 | + true |
| 84 | + ) |
| 85 | + }) |
71 | 86 |
|
72 |
| - assert.equal( |
73 |
| - labelable({ |
74 |
| - type: 'element', |
75 |
| - tagName: 'meter', |
76 |
| - properties: {}, |
77 |
| - children: [] |
78 |
| - }), |
79 |
| - true, |
80 |
| - 'should return `true` for `meter` elements' |
81 |
| - ) |
| 87 | + await t.test('should return `true` for `meter` elements', async function () { |
| 88 | + assert.equal( |
| 89 | + labelable({ |
| 90 | + type: 'element', |
| 91 | + tagName: 'meter', |
| 92 | + properties: {}, |
| 93 | + children: [] |
| 94 | + }), |
| 95 | + true |
| 96 | + ) |
| 97 | + }) |
82 | 98 |
|
83 |
| - assert.equal( |
84 |
| - labelable({ |
85 |
| - type: 'element', |
86 |
| - tagName: 'output', |
87 |
| - properties: {}, |
88 |
| - children: [] |
89 |
| - }), |
90 |
| - true, |
91 |
| - 'should return `true` for `output` elements' |
92 |
| - ) |
| 99 | + await t.test('should return `true` for `output` elements', async function () { |
| 100 | + assert.equal( |
| 101 | + labelable({ |
| 102 | + type: 'element', |
| 103 | + tagName: 'output', |
| 104 | + properties: {}, |
| 105 | + children: [] |
| 106 | + }), |
| 107 | + true |
| 108 | + ) |
| 109 | + }) |
93 | 110 |
|
94 |
| - assert.equal( |
95 |
| - labelable({ |
96 |
| - type: 'element', |
97 |
| - tagName: 'progress', |
98 |
| - properties: {}, |
99 |
| - children: [] |
100 |
| - }), |
101 |
| - true, |
102 |
| - 'should return `true` for `progress` elements' |
| 111 | + await t.test( |
| 112 | + 'should return `true` for `progress` elements', |
| 113 | + async function () { |
| 114 | + assert.equal( |
| 115 | + labelable({ |
| 116 | + type: 'element', |
| 117 | + tagName: 'progress', |
| 118 | + properties: {}, |
| 119 | + children: [] |
| 120 | + }), |
| 121 | + true |
| 122 | + ) |
| 123 | + } |
103 | 124 | )
|
104 | 125 |
|
105 |
| - assert.equal( |
106 |
| - labelable({ |
107 |
| - type: 'element', |
108 |
| - tagName: 'select', |
109 |
| - properties: {}, |
110 |
| - children: [] |
111 |
| - }), |
112 |
| - true, |
113 |
| - 'should return `true` for `select` elements' |
114 |
| - ) |
| 126 | + await t.test('should return `true` for `select` elements', async function () { |
| 127 | + assert.equal( |
| 128 | + labelable({ |
| 129 | + type: 'element', |
| 130 | + tagName: 'select', |
| 131 | + properties: {}, |
| 132 | + children: [] |
| 133 | + }), |
| 134 | + true |
| 135 | + ) |
| 136 | + }) |
115 | 137 |
|
116 |
| - assert.equal( |
117 |
| - labelable({ |
118 |
| - type: 'element', |
119 |
| - tagName: 'textarea', |
120 |
| - properties: {}, |
121 |
| - children: [] |
122 |
| - }), |
123 |
| - true, |
124 |
| - 'should return `true` for `textarea` elements' |
| 138 | + await t.test( |
| 139 | + 'should return `true` for `textarea` elements', |
| 140 | + async function () { |
| 141 | + assert.equal( |
| 142 | + labelable({ |
| 143 | + type: 'element', |
| 144 | + tagName: 'textarea', |
| 145 | + properties: {}, |
| 146 | + children: [] |
| 147 | + }), |
| 148 | + true |
| 149 | + ) |
| 150 | + } |
125 | 151 | )
|
126 | 152 | })
|
0 commit comments