Skip to content

Commit 422cabe

Browse files
committed
Refactor code-style
1 parent 7a51a9f commit 422cabe

File tree

1 file changed

+46
-36
lines changed

1 file changed

+46
-36
lines changed

test.js

Lines changed: 46 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,60 @@
11
import assert from 'node:assert/strict'
22
import test from 'node:test'
33
import {heading} from './index.js'
4-
import * as mod from './index.js'
54

6-
test('heading', () => {
7-
assert.deepEqual(
8-
Object.keys(mod).sort(),
9-
['heading'],
10-
'should expose the public api'
11-
)
5+
test('heading', 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+
'heading'
9+
])
10+
})
1211

13-
// @ts-expect-error: check how a missing `node` is handled.
14-
assert.equal(heading(), false, 'should return `false` without node')
12+
await t.test('should return `false` without node', async function () {
13+
// @ts-expect-error: check how a missing `node` is handled.
14+
assert.equal(heading(), false)
15+
})
1516

16-
assert.equal(heading(null), false, 'should return `false` with `null`')
17+
await t.test('should return `false` with `null`', async function () {
18+
assert.equal(heading(null), false)
19+
})
1720

18-
assert.equal(
19-
heading({type: 'text'}),
20-
false,
21-
'should return `false` when without `element`'
21+
await t.test(
22+
'should return `false` when without `element`',
23+
async function () {
24+
assert.equal(heading({type: 'text'}), false)
25+
}
2226
)
2327

24-
assert.equal(
25-
heading({type: 'element'}),
26-
false,
27-
'should return `false` when with invalid `element`'
28+
await t.test(
29+
'should return `false` when with invalid `element`',
30+
async function () {
31+
assert.equal(heading({type: 'element'}), false)
32+
}
2833
)
2934

30-
assert.equal(
31-
heading({
32-
type: 'element',
33-
tagName: 'a',
34-
properties: {href: '#alpha', title: 'Bravo'},
35-
children: [{type: 'text', value: 'Charlie'}]
36-
}),
37-
false,
38-
'should return `false` when without not heading'
35+
await t.test(
36+
'should return `false` when without not heading',
37+
async function () {
38+
assert.equal(
39+
heading({
40+
type: 'element',
41+
tagName: 'a',
42+
properties: {href: '#alpha', title: 'Bravo'},
43+
children: [{type: 'text', value: 'Charlie'}]
44+
}),
45+
false
46+
)
47+
}
3948
)
4049

41-
assert.equal(
42-
heading({
43-
type: 'element',
44-
tagName: 'h1',
45-
children: [{type: 'text', value: 'Delta'}]
46-
}),
47-
true,
48-
'should return `true` when with heading'
49-
)
50+
await t.test('should return `true` when with heading', async function () {
51+
assert.equal(
52+
heading({
53+
type: 'element',
54+
tagName: 'h1',
55+
children: [{type: 'text', value: 'Delta'}]
56+
}),
57+
true
58+
)
59+
})
5060
})

0 commit comments

Comments
 (0)