33 * @typedef {import('unist').Parent } Parent
44 */
55
6- import test from 'tape'
6+ import assert from 'node:assert/strict'
7+ import test from 'node:test'
78import { fromMarkdown } from 'mdast-util-from-markdown'
89import { findAfter } from './index.js'
910
1011const tree = fromMarkdown ( 'Some _emphasis_, **importance**, and `code`.' )
1112const paragraph = /** @type {Parent } */ ( tree . children [ 0 ] )
1213const children = paragraph . children
1314
14- test ( 'unist-util-find-after' , ( t ) => {
15- t . throws (
15+ test ( 'unist-util-find-after' , ( ) => {
16+ assert . throws (
1617 ( ) => {
1718 // @ts -expect-error runtime.
1819 findAfter ( )
@@ -21,7 +22,7 @@ test('unist-util-find-after', (t) => {
2122 'should fail without parent'
2223 )
2324
24- t . throws (
25+ assert . throws (
2526 ( ) => {
2627 // @ts -expect-error runtime.
2728 findAfter ( { type : 'foo' } )
@@ -30,7 +31,7 @@ test('unist-util-find-after', (t) => {
3031 'should fail without parent node'
3132 )
3233
33- t . throws (
34+ assert . throws (
3435 ( ) => {
3536 // @ts -expect-error runtime.
3637 findAfter ( { type : 'foo' , children : [ ] } )
@@ -39,23 +40,23 @@ test('unist-util-find-after', (t) => {
3940 'should fail without index (#1)'
4041 )
4142
42- t . throws (
43+ assert . throws (
4344 ( ) => {
4445 findAfter ( { type : 'foo' , children : [ ] } , - 1 )
4546 } ,
4647 / 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 / ,
4748 'should fail without index (#2)'
4849 )
4950
50- t . throws (
51+ assert . throws (
5152 ( ) => {
5253 findAfter ( { type : 'foo' , children : [ ] } , { type : 'bar' } )
5354 } ,
5455 / E x p e c t e d c h i l d n o d e o r i n d e x / ,
5556 'should fail without index (#3)'
5657 )
5758
58- t . throws (
59+ assert . throws (
5960 ( ) => {
6061 findAfter (
6162 { type : 'foo' , children : [ { type : 'bar' } , { type : 'baz' } ] } ,
@@ -68,7 +69,7 @@ test('unist-util-find-after', (t) => {
6869 'should fail for invalid `test` (#1)'
6970 )
7071
71- t . throws (
72+ assert . throws (
7273 ( ) => {
7374 findAfter (
7475 { type : 'foo' , children : [ { type : 'bar' } , { type : 'baz' } ] } ,
@@ -81,102 +82,100 @@ test('unist-util-find-after', (t) => {
8182 'should fail for invalid `test` (#2)'
8283 )
8384
84- t . strictEqual (
85+ assert . strictEqual (
8586 findAfter ( paragraph , children [ 1 ] ) ,
8687 children [ 2 ] ,
8788 'should return the following node when without `test` (#1)'
8889 )
89- t . strictEqual (
90+ assert . strictEqual (
9091 findAfter ( paragraph , 1 ) ,
9192 children [ 2 ] ,
9293 'should return the following node when without `test` (#1)'
9394 )
94- t . strictEqual (
95+ assert . strictEqual (
9596 findAfter ( paragraph , 7 ) ,
9697 null ,
9798 'should return the following node when without `test` (#1)'
9899 )
99100
100- t . strictEqual (
101+ assert . strictEqual (
101102 findAfter ( paragraph , 0 , children [ 6 ] ) ,
102103 children [ 6 ] ,
103104 'should return `node` when given a `node` and existing (#1)'
104105 )
105- t . strictEqual (
106+ assert . strictEqual (
106107 findAfter ( paragraph , children [ 0 ] , children [ 1 ] ) ,
107108 children [ 1 ] ,
108109 'should return `node` when given a `node` and existing (#2)'
109110 )
110- t . strictEqual (
111+ assert . strictEqual (
111112 findAfter ( paragraph , 0 , children [ 1 ] ) ,
112113 children [ 1 ] ,
113114 'should return `node` when given a `node` and existing (#3)'
114115 )
115- t . strictEqual (
116+ assert . strictEqual (
116117 findAfter ( paragraph , children [ 0 ] , children [ 0 ] ) ,
117118 null ,
118119 'should return `node` when given a `node` and existing (#4)'
119120 )
120- t . strictEqual (
121+ assert . strictEqual (
121122 findAfter ( paragraph , 0 , children [ 0 ] ) ,
122123 null ,
123124 'should return `node` when given a `node` and existing (#5)'
124125 )
125- t . strictEqual (
126+ assert . strictEqual (
126127 findAfter ( paragraph , 1 , children [ 1 ] ) ,
127128 null ,
128129 'should return `node` when given a `node` and existing (#6)'
129130 )
130131
131- t . strictEqual (
132+ assert . strictEqual (
132133 findAfter ( paragraph , 0 , 'strong' ) ,
133134 children [ 3 ] ,
134135 'should return a child when given a `type` and existing (#1)'
135136 )
136- t . strictEqual (
137+ assert . strictEqual (
137138 findAfter ( paragraph , 3 , 'strong' ) ,
138139 null ,
139140 'should return a child when given a `type` and existing (#2)'
140141 )
141- t . strictEqual (
142+ assert . strictEqual (
142143 findAfter ( paragraph , children [ 0 ] , 'strong' ) ,
143144 children [ 3 ] ,
144145 'should return a child when given a `type` and existing (#3)'
145146 )
146- t . strictEqual (
147+ assert . strictEqual (
147148 findAfter ( paragraph , children [ 3 ] , 'strong' ) ,
148149 null ,
149150 'should return a child when given a `type` and existing (#4)'
150151 )
151152
152- t . strictEqual (
153- findAfter ( paragraph , 0 , test ) ,
153+ assert . strictEqual (
154+ findAfter ( paragraph , 0 , check ) ,
154155 children [ 5 ] ,
155156 'should return a child when given a `test` and existing (#1)'
156157 )
157- t . strictEqual (
158- findAfter ( paragraph , 5 , test ) ,
158+ assert . strictEqual (
159+ findAfter ( paragraph , 5 , check ) ,
159160 null ,
160161 'should return a child when given a `test` and existing (#2)'
161162 )
162- t . strictEqual (
163- findAfter ( paragraph , children [ 4 ] , test ) ,
163+ assert . strictEqual (
164+ findAfter ( paragraph , children [ 4 ] , check ) ,
164165 children [ 5 ] ,
165166 'should return a child when given a `test` and existing (#3)'
166167 )
167- t . strictEqual (
168- findAfter ( paragraph , children [ 6 ] , test ) ,
168+ assert . strictEqual (
169+ findAfter ( paragraph , children [ 6 ] , check ) ,
169170 null ,
170171 'should return a child when given a `test` and existing (#4)'
171172 )
172173
173174 /**
174175 * @param {Node } _
175- * @param {number } n
176+ * @param {number | null | undefined } n
176177 */
177- function test ( _ , n ) {
178+ function check ( _ , n ) {
178179 return n === 5
179180 }
180-
181- t . end ( )
182181} )
0 commit comments