22 * @typedef {import('unist').Node } Node
33 */
44
5- import assert from 'node:assert'
6- import test from 'tape '
5+ import assert from 'node:assert/strict '
6+ import test from 'node:test '
77import { fromMarkdown } from 'mdast-util-from-markdown'
88import { findBefore } from './index.js'
99
10- test ( '`findBefore`' , ( t ) => {
10+ test ( '`findBefore`' , ( ) => {
1111 const tree = fromMarkdown ( 'Some *emphasis*, **importance**, and `code`.' )
1212
1313 assert ( tree . type === 'root' )
@@ -18,7 +18,7 @@ test('`findBefore`', (t) => {
1818 const next = paragraph . children [ 1 ]
1919 assert ( next . type === 'emphasis' )
2020
21- t . throws (
21+ assert . throws (
2222 ( ) => {
2323 // @ts -expect-error runtime
2424 findBefore ( )
@@ -27,7 +27,7 @@ test('`findBefore`', (t) => {
2727 'should fail without parent'
2828 )
2929
30- t . throws (
30+ assert . throws (
3131 ( ) => {
3232 // @ts -expect-error runtime
3333 findBefore ( { type : 'foo' } )
@@ -36,7 +36,7 @@ test('`findBefore`', (t) => {
3636 'should fail without parent node'
3737 )
3838
39- t . throws (
39+ assert . throws (
4040 ( ) => {
4141 // @ts -expect-error runtime
4242 findBefore ( { type : 'foo' , children : [ ] } )
@@ -45,23 +45,23 @@ test('`findBefore`', (t) => {
4545 'should fail without index (#1)'
4646 )
4747
48- t . throws (
48+ assert . throws (
4949 ( ) => {
5050 findBefore ( { type : 'foo' , children : [ ] } , - 1 )
5151 } ,
5252 / E x p e c t e d p o s i t i v e f i n i t e n u m b e r a s i n d e x / ,
5353 'should fail without index (#2)'
5454 )
5555
56- t . throws (
56+ assert . throws (
5757 ( ) => {
5858 findBefore ( { type : 'foo' , children : [ ] } , { type : 'bar' } )
5959 } ,
6060 / E x p e c t e d c h i l d n o d e o r i n d e x / ,
6161 'should fail without index (#3)'
6262 )
6363
64- t . throws (
64+ assert . throws (
6565 ( ) => {
6666 // @ts -expect-error runtime
6767 findBefore ( { type : 'foo' , children : [ { type : 'bar' } ] } , 1 , false )
@@ -70,7 +70,7 @@ test('`findBefore`', (t) => {
7070 'should fail for invalid `test` (#1)'
7171 )
7272
73- t . throws (
73+ assert . throws (
7474 ( ) => {
7575 // @ts -expect-error runtime
7676 findBefore ( { type : 'foo' , children : [ { type : 'bar' } ] } , 1 , true )
@@ -79,102 +79,100 @@ test('`findBefore`', (t) => {
7979 'should fail for invalid `test` (#2)'
8080 )
8181
82- t . strictEqual (
82+ assert . strictEqual (
8383 findBefore ( paragraph , paragraph . children [ 1 ] ) ,
8484 head ,
8585 'should return the preceding node when without `test` (#1)'
8686 )
87- t . strictEqual (
87+ assert . strictEqual (
8888 findBefore ( paragraph , 1 ) ,
8989 head ,
9090 'should return the preceding node when without `test` (#2)'
9191 )
92- t . strictEqual (
92+ assert . strictEqual (
9393 findBefore ( paragraph , 0 ) ,
9494 null ,
9595 'should return the preceding node when without `test` (#3)'
9696 )
9797
98- t . strictEqual (
98+ assert . strictEqual (
9999 findBefore ( paragraph , 100 , head ) ,
100100 head ,
101101 'should return `node` when given a `node` and existing (#1)'
102102 )
103- t . strictEqual (
103+ assert . strictEqual (
104104 findBefore ( paragraph , paragraph . children [ 1 ] , head ) ,
105105 head ,
106106 'should return `node` when given a `node` and existing (#2)'
107107 )
108- t . strictEqual (
108+ assert . strictEqual (
109109 findBefore ( paragraph , 1 , head ) ,
110110 head ,
111111 'should return `node` when given a `node` and existing (#3)'
112112 )
113- t . strictEqual (
113+ assert . strictEqual (
114114 findBefore ( paragraph , head , head ) ,
115115 null ,
116116 'should return `node` when given a `node` and existing (#4)'
117117 )
118- t . strictEqual (
118+ assert . strictEqual (
119119 findBefore ( paragraph , 0 , head ) ,
120120 null ,
121121 'should return `node` when given a `node` and existing (#5)'
122122 )
123- t . strictEqual (
123+ assert . strictEqual (
124124 findBefore ( paragraph , 1 , next ) ,
125125 null ,
126126 'should return `node` when given a `node` and existing (#6)'
127127 )
128128
129- t . strictEqual (
129+ assert . strictEqual (
130130 findBefore ( paragraph , 100 , 'strong' ) ,
131131 paragraph . children [ 3 ] ,
132132 'should return a child when given a `type` and existing (#1)'
133133 )
134- t . strictEqual (
134+ assert . strictEqual (
135135 findBefore ( paragraph , 3 , 'strong' ) ,
136136 null ,
137137 'should return a child when given a `type` and existing (#2)'
138138 )
139- t . strictEqual (
139+ assert . strictEqual (
140140 findBefore ( paragraph , paragraph . children [ 4 ] , 'strong' ) ,
141141 paragraph . children [ 3 ] ,
142142 'should return a child when given a `type` and existing (#3)'
143143 )
144- t . strictEqual (
144+ assert . strictEqual (
145145 findBefore ( paragraph , paragraph . children [ 3 ] , 'strong' ) ,
146146 null ,
147147 'should return a child when given a `type` and existing (#4)'
148148 )
149149
150- t . strictEqual (
151- findBefore ( paragraph , 100 , test ) ,
150+ assert . strictEqual (
151+ findBefore ( paragraph , 100 , check ) ,
152152 paragraph . children [ 3 ] ,
153153 'should return a child when given a `test` and existing (#1)'
154154 )
155- t . strictEqual (
156- findBefore ( paragraph , 3 , test ) ,
155+ assert . strictEqual (
156+ findBefore ( paragraph , 3 , check ) ,
157157 null ,
158158 'should return a child when given a `test` and existing (#2)'
159159 )
160- t . strictEqual (
161- findBefore ( paragraph , paragraph . children [ 4 ] , test ) ,
160+ assert . strictEqual (
161+ findBefore ( paragraph , paragraph . children [ 4 ] , check ) ,
162162 paragraph . children [ 3 ] ,
163163 'should return a child when given a `test` and existing (#3)'
164164 )
165- t . strictEqual (
166- findBefore ( paragraph , paragraph . children [ 3 ] , test ) ,
165+ assert . strictEqual (
166+ findBefore ( paragraph , paragraph . children [ 3 ] , check ) ,
167167 null ,
168168 'should return a child when given a `test` and existing (#4)'
169169 )
170170
171171 /**
172172 * @param {Node } _
173- * @param {number } n
173+ * @param {number | null | undefined } n
174174 */
175- function test ( _ , n ) {
175+ function check ( _ , n ) {
176176 return n === 3
177177 }
178-
179- t . end ( )
180178} )
0 commit comments