|
1 | 1 | import assert from 'node:assert/strict'
|
2 | 2 | import test from 'node:test'
|
3 | 3 | import {heading} from './index.js'
|
4 |
| -import * as mod from './index.js' |
5 | 4 |
|
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 | + }) |
12 | 11 |
|
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 | + }) |
15 | 16 |
|
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 | + }) |
17 | 20 |
|
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 | + } |
22 | 26 | )
|
23 | 27 |
|
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 | + } |
28 | 33 | )
|
29 | 34 |
|
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 | + } |
39 | 48 | )
|
40 | 49 |
|
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 | + }) |
50 | 60 | })
|
0 commit comments