1
+ /**
2
+ * @typedef {import('mdast').Root } Root
3
+ */
4
+
1
5
import assert from 'node:assert/strict'
2
6
import test from 'node:test'
3
7
import { fromMarkdown } from 'mdast-util-from-markdown'
@@ -21,9 +25,7 @@ test('definitions', () => {
21
25
)
22
26
23
27
assert . deepEqual (
24
- definitions ( fromMarkdown ( '[example]: https://example.com "Example"' ) ) (
25
- 'example'
26
- ) ,
28
+ definitions ( from ( '[example]: https://example.com "Example"' ) ) ( 'example' ) ,
27
29
{
28
30
type : 'definition' ,
29
31
identifier : 'example' ,
@@ -39,17 +41,13 @@ test('definitions', () => {
39
41
)
40
42
41
43
assert . equal (
42
- definitions ( fromMarkdown ( '[example]: https://example.com "Example"' ) ) (
43
- 'foo'
44
- ) ,
44
+ definitions ( from ( '[example]: https://example.com "Example"' ) ) ( 'foo' ) ,
45
45
null ,
46
46
'should return null when not found'
47
47
)
48
48
49
49
assert . deepEqual (
50
- definitions ( fromMarkdown ( '[__proto__]: https://proto.com "Proto"' ) ) (
51
- '__proto__'
52
- ) ,
50
+ definitions ( from ( '[__proto__]: https://proto.com "Proto"' ) ) ( '__proto__' ) ,
53
51
{
54
52
type : 'definition' ,
55
53
identifier : '__proto__' ,
@@ -71,15 +69,13 @@ test('definitions', () => {
71
69
/* eslint-enable no-use-extend-native/no-use-extend-native */
72
70
73
71
assert . deepEqual (
74
- definitions ( fromMarkdown ( '[__proto__]: https://proto.com "Proto"' ) ) (
75
- 'toString'
76
- ) ,
72
+ definitions ( from ( '[__proto__]: https://proto.com "Proto"' ) ) ( 'toString' ) ,
77
73
null ,
78
74
'should work on weird identifiers when not found'
79
75
)
80
76
81
77
const example = definitions (
82
- fromMarkdown ( '[example]: https://one.com\n[example]: https://two.com' )
78
+ from ( '[example]: https://one.com\n[example]: https://two.com' )
83
79
) ( 'example' )
84
80
85
81
assert . deepEqual (
@@ -89,10 +85,20 @@ test('definitions', () => {
89
85
)
90
86
91
87
assert . deepEqual (
92
- definitions (
93
- fromMarkdown ( '[example]: https://one.com\n[example]: https://two.com' )
94
- ) ( '' ) ,
88
+ definitions ( from ( '[example]: https://one.com\n[example]: https://two.com' ) ) (
89
+ ''
90
+ ) ,
95
91
null ,
96
92
'should not return something for a missing identifier'
97
93
)
98
94
} )
95
+
96
+ /**
97
+ *
98
+ * @param {string } value
99
+ * @returns {Root }
100
+ */
101
+ function from ( value ) {
102
+ // @ts -expect-error: To do: remove cast when `from-markdown` is released.
103
+ return fromMarkdown ( value )
104
+ }
0 commit comments