55import assert from 'node:assert/strict'
66import fs from 'node:fs/promises'
77import test from 'node:test'
8+ import { isHidden } from 'is-hidden'
89import { fromMarkdown } from 'mdast-util-from-markdown'
910import { toMarkdown } from 'mdast-util-to-markdown'
10- import { isHidden } from 'is-hidden'
11- import * as mod from '../index.js'
1211
13- test ( 'zone' , async ( ) => {
14- assert . deepEqual (
15- Object . keys ( mod ) . sort ( ) ,
16- [ 'zone' ] ,
17- 'should expose the public api'
18- )
12+ test ( 'zone' , async function ( t ) {
13+ await t . test ( 'should expose the public api' , async function ( ) {
14+ assert . deepEqual ( Object . keys ( await import ( '../index.js' ) ) . sort ( ) , [ 'zone' ] )
15+ } )
1916
2017 const root = new URL ( 'fixtures/' , import . meta. url )
2118 const folders = await fs . readdir ( root )
@@ -26,26 +23,30 @@ test('zone', async () => {
2623
2724 if ( isHidden ( folder ) ) continue
2825
29- /** @type {string | undefined } */
30- let expected
26+ await t . test ( 'should work on `' + folder + '`' , async function ( ) {
27+ /** @type {string | undefined } */
28+ let expected
3129
32- try {
33- expected = String ( await fs . readFile ( new URL ( folder + '/output.md' , root ) ) )
34- } catch { }
30+ try {
31+ expected = String (
32+ await fs . readFile ( new URL ( folder + '/output.md' , root ) )
33+ )
34+ } catch { }
3535
36- /** @type {{default: (tree: Root) => void } } */
37- const mod = await import ( new URL ( folder + '/index.js' , root ) . href )
38- const check = mod . default
39- // To do: remove cast when `from-markdown` is released.
40- const tree = /** @type {Root } */ (
41- fromMarkdown ( await fs . readFile ( new URL ( folder + '/input.md' , root ) ) )
42- )
36+ /** @type {{default: (tree: Root) => undefined } } */
37+ const mod = await import ( new URL ( folder + '/index.js' , root ) . href )
38+ const check = mod . default
39+ // To do: remove cast when `from-markdown` is released.
40+ const tree = /** @type {Root } */ (
41+ fromMarkdown ( await fs . readFile ( new URL ( folder + '/input.md' , root ) ) )
42+ )
4343
44- check ( tree )
44+ check ( tree )
4545
46- // @ts -expect-error: remove cast when `to-markdown` is released.
47- const result = toMarkdown ( tree )
46+ // @ts -expect-error: remove cast when `to-markdown` is released.
47+ const result = toMarkdown ( tree )
4848
49- assert . equal ( result , expected , folder )
49+ assert . equal ( result , expected )
50+ } )
5051 }
5152} )
0 commit comments