@@ -8,88 +8,98 @@ import {fromMarkdown} from 'mdast-util-from-markdown'
8
8
import { definitions } from './index.js'
9
9
import * as mod from './index.js'
10
10
11
- test ( 'definitions' , ( ) => {
12
- assert . deepEqual (
13
- Object . keys ( mod ) . sort ( ) ,
14
- [ 'definitions' ] ,
15
- 'should expose the public api'
16
- )
11
+ test ( 'definitions' , async function ( t ) {
12
+ await t . test ( 'should expose the public api' , async function ( ) {
13
+ assert . deepEqual ( Object . keys ( mod ) . sort ( ) , [ 'definitions' ] )
14
+ } )
17
15
18
- assert . throws (
19
- ( ) => {
16
+ await t . test ( 'should fail without node' , async function ( ) {
17
+ assert . throws ( function ( ) {
20
18
// @ts -expect-error runtime
21
19
definitions ( )
22
- } ,
23
- / m d a s t - u t i l - d e f i n i t i o n s e x p e c t e d n o d e / ,
24
- 'should fail without node'
25
- )
20
+ } , / m d a s t - u t i l - d e f i n i t i o n s e x p e c t e d n o d e / )
21
+ } )
26
22
27
- assert . deepEqual (
28
- definitions ( from ( '[example]: https://example.com "Example"' ) ) ( 'example' ) ,
29
- {
30
- type : 'definition' ,
31
- identifier : 'example' ,
32
- label : 'example' ,
33
- title : 'Example' ,
34
- url : 'https://example.com' ,
35
- position : {
36
- start : { line : 1 , column : 1 , offset : 0 } ,
37
- end : { line : 1 , column : 41 , offset : 40 }
23
+ await t . test ( 'should return a definition' , async function ( ) {
24
+ assert . deepEqual (
25
+ definitions ( from ( '[example]: https://example.com "Example"' ) ) ( 'example' ) ,
26
+ {
27
+ type : 'definition' ,
28
+ identifier : 'example' ,
29
+ label : 'example' ,
30
+ title : 'Example' ,
31
+ url : 'https://example.com' ,
32
+ position : {
33
+ start : { line : 1 , column : 1 , offset : 0 } ,
34
+ end : { line : 1 , column : 41 , offset : 40 }
35
+ }
38
36
}
39
- } ,
40
- 'should return a definition'
41
- )
37
+ )
38
+ } )
42
39
43
- assert . equal (
44
- definitions ( from ( '[example]: https://example.com "Example"' ) ) ( 'foo' ) ,
45
- null ,
46
- 'should return null when not found'
47
- )
40
+ await t . test ( 'should return null when not found' , async function ( ) {
41
+ assert . equal (
42
+ definitions ( from ( '[example]: https://example.com "Example"' ) ) ( 'foo' ) ,
43
+ null
44
+ )
45
+ } )
48
46
49
- assert . deepEqual (
50
- definitions ( from ( '[__proto__]: https://proto.com "Proto"' ) ) ( '__proto__' ) ,
51
- {
52
- type : 'definition' ,
53
- identifier : '__proto__' ,
54
- label : '__proto__' ,
55
- title : 'Proto' ,
56
- url : 'https://proto.com' ,
57
- position : {
58
- start : { line : 1 , column : 1 , offset : 0 } ,
59
- end : { line : 1 , column : 39 , offset : 38 }
47
+ await t . test ( 'should work on weird identifiers' , async function ( ) {
48
+ assert . deepEqual (
49
+ definitions ( from ( '[__proto__]: https://proto.com "Proto"' ) ) ( '__proto__' ) ,
50
+ {
51
+ type : 'definition' ,
52
+ identifier : '__proto__' ,
53
+ label : '__proto__' ,
54
+ title : 'Proto' ,
55
+ url : 'https://proto.com' ,
56
+ position : {
57
+ start : { line : 1 , column : 1 , offset : 0 } ,
58
+ end : { line : 1 , column : 39 , offset : 38 }
59
+ }
60
60
}
61
- } ,
62
- 'should work on weird identifiers'
63
- )
61
+ )
62
+ } )
64
63
65
- /* eslint-disable no-use-extend-native/no-use-extend-native */
66
- // @ts -expect-error: yes.
67
- // type-coverage:ignore-next-line
68
- assert . equal ( { } . type , undefined , 'should not polute the prototype' )
69
- /* eslint-enable no-use-extend-native/no-use-extend-native */
64
+ await t . test ( 'should not polute the prototype' , async function ( ) {
65
+ /* eslint-disable no-use-extend-native/no-use-extend-native */
66
+ // @ts -expect-error: yes.
67
+ // type-coverage:ignore-next-line
68
+ assert . equal ( { } . type , undefined )
69
+ /* eslint-enable no-use-extend-native/no-use-extend-native */
70
+ } )
70
71
71
- assert . deepEqual (
72
- definitions ( from ( '[__proto__]: https://proto.com "Proto"' ) ) ( 'toString' ) ,
73
- null ,
74
- 'should work on weird identifiers when not found'
72
+ await t . test (
73
+ 'should work on weird identifiers when not found' ,
74
+ async function ( ) {
75
+ assert . deepEqual (
76
+ definitions ( from ( '[__proto__]: https://proto.com "Proto"' ) ) ( 'toString' ) ,
77
+ null
78
+ )
79
+ }
75
80
)
76
81
77
- const example = definitions (
78
- from ( '[example]: https://one.com\n[example]: https://two.com' )
79
- ) ( 'example' )
82
+ await t . test (
83
+ 'should prefer the first of duplicate definitions' ,
84
+ async function ( ) {
85
+ const example = definitions (
86
+ from ( '[example]: https://one.com\n[example]: https://two.com' )
87
+ ) ( 'example' )
80
88
81
- assert . deepEqual (
82
- example && example . url ,
83
- 'https://one.com' ,
84
- 'should prefer the first of duplicate definitions'
89
+ assert . deepEqual ( example && example . url , 'https://one.com' )
90
+ }
85
91
)
86
92
87
- assert . deepEqual (
88
- definitions ( from ( '[example]: https://one.com\n[example]: https://two.com' ) ) (
89
- ''
90
- ) ,
91
- null ,
92
- 'should not return something for a missing identifier'
93
+ await t . test (
94
+ 'should not return something for a missing identifier' ,
95
+ async function ( ) {
96
+ assert . deepEqual (
97
+ definitions (
98
+ from ( '[example]: https://one.com\n[example]: https://two.com' )
99
+ ) ( '' ) ,
100
+ null
101
+ )
102
+ }
93
103
)
94
104
} )
95
105
0 commit comments