1
- import test from 'tape'
1
+ import assert from 'node:assert/strict'
2
+ import test from 'node:test'
2
3
import { h } from 'hastscript'
3
4
import { shiftHeading } from './index.js'
4
5
5
- test ( 'shiftHeading' , ( t ) => {
6
- t . throws (
6
+ test ( 'shiftHeading' , ( ) => {
7
+ assert . throws (
7
8
( ) => {
8
9
// @ts -ignore runtime.
9
10
shiftHeading ( h ( '' ) )
@@ -12,70 +13,68 @@ test('shiftHeading', (t) => {
12
13
'should throw when not given a number'
13
14
)
14
15
15
- t . throws (
16
+ assert . throws (
16
17
( ) => {
17
18
shiftHeading ( h ( '' ) , Number . NaN )
18
19
} ,
19
20
/ ^ E r r o r : E x p e c t e d a n o n - n u l l f i n i t e i n t e g e r , n o t ` N a N ` $ / ,
20
21
'should throw when given not a number'
21
22
)
22
23
23
- t . throws (
24
+ assert . throws (
24
25
( ) => {
25
26
shiftHeading ( h ( '' ) , 0.1 )
26
27
} ,
27
28
/ ^ E r r o r : E x p e c t e d a n o n - n u l l f i n i t e i n t e g e r , n o t ` 0 .1 ` $ / ,
28
29
'should throw when not given an integer'
29
30
)
30
31
31
- t . throws (
32
+ assert . throws (
32
33
( ) => {
33
34
shiftHeading ( h ( '' ) , Number . POSITIVE_INFINITY )
34
35
} ,
35
36
/ ^ E r r o r : E x p e c t e d a n o n - n u l l f i n i t e i n t e g e r , n o t ` I n f i n i t y ` $ / ,
36
37
'should throw when not given a finite number'
37
38
)
38
39
39
- t . throws (
40
+ assert . throws (
40
41
( ) => {
41
42
shiftHeading ( h ( '' ) , 0 )
42
43
} ,
43
44
/ ^ E r r o r : E x p e c t e d a n o n - n u l l f i n i t e i n t e g e r , n o t ` 0 ` $ / ,
44
45
'should throw when not given a non-null number'
45
46
)
46
47
47
- t . deepEqual (
48
+ assert . deepEqual (
48
49
shiftHeading ( h ( 'h1' , 'Alpha' ) , 1 ) ,
49
50
h ( 'h2' , 'Alpha' ) ,
50
51
'should shift nodes upwards'
51
52
)
52
53
53
- t . deepEqual (
54
+ assert . deepEqual (
54
55
shiftHeading ( h ( 'h2' , 'Bravo' ) , - 1 ) ,
55
56
h ( 'h1' , 'Bravo' ) ,
56
57
'should shift nodes downwards'
57
58
)
58
59
59
- t . deepEqual (
60
+ assert . deepEqual (
60
61
shiftHeading ( h ( 'h2' , 'Charlie' ) , - 2 ) ,
61
62
h ( 'h1' , 'Charlie' ) ,
62
63
'should not shift upwards past h1'
63
64
)
64
65
65
- t . deepEqual (
66
+ assert . deepEqual (
66
67
shiftHeading ( h ( 'h5' , 'Delta' ) , 2 ) ,
67
68
h ( 'h6' , 'Delta' ) ,
68
69
'should not shift downwards past h6'
69
70
)
70
71
71
- t . deepEqual (
72
+ assert . deepEqual (
72
73
shiftHeading (
73
74
h ( 'main' , [ h ( 'h1' , 'Echo' ) , h ( 'p' , 'Foxtrot' ) , h ( 'h5' , 'Golf' ) ] ) ,
74
75
2
75
76
) ,
76
77
h ( 'main' , [ h ( 'h3' , 'Echo' ) , h ( 'p' , 'Foxtrot' ) , h ( 'h6' , 'Golf' ) ] ) ,
77
78
'should change a tree'
78
79
)
79
-
80
- t . end ( )
81
80
} )
0 commit comments