1+ /**
2+ * @typedef {import('mdast').Root } Root
3+ */
4+
15import assert from 'node:assert/strict'
26import test from 'node:test'
37import { fromMarkdown } from 'mdast-util-from-markdown'
@@ -21,9 +25,7 @@ test('definitions', () => {
2125 )
2226
2327 assert . deepEqual (
24- definitions ( fromMarkdown ( '[example]: https://example.com "Example"' ) ) (
25- 'example'
26- ) ,
28+ definitions ( from ( '[example]: https://example.com "Example"' ) ) ( 'example' ) ,
2729 {
2830 type : 'definition' ,
2931 identifier : 'example' ,
@@ -39,17 +41,13 @@ test('definitions', () => {
3941 )
4042
4143 assert . equal (
42- definitions ( fromMarkdown ( '[example]: https://example.com "Example"' ) ) (
43- 'foo'
44- ) ,
44+ definitions ( from ( '[example]: https://example.com "Example"' ) ) ( 'foo' ) ,
4545 null ,
4646 'should return null when not found'
4747 )
4848
4949 assert . deepEqual (
50- definitions ( fromMarkdown ( '[__proto__]: https://proto.com "Proto"' ) ) (
51- '__proto__'
52- ) ,
50+ definitions ( from ( '[__proto__]: https://proto.com "Proto"' ) ) ( '__proto__' ) ,
5351 {
5452 type : 'definition' ,
5553 identifier : '__proto__' ,
@@ -71,15 +69,13 @@ test('definitions', () => {
7169 /* eslint-enable no-use-extend-native/no-use-extend-native */
7270
7371 assert . deepEqual (
74- definitions ( fromMarkdown ( '[__proto__]: https://proto.com "Proto"' ) ) (
75- 'toString'
76- ) ,
72+ definitions ( from ( '[__proto__]: https://proto.com "Proto"' ) ) ( 'toString' ) ,
7773 null ,
7874 'should work on weird identifiers when not found'
7975 )
8076
8177 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' )
8379 ) ( 'example' )
8480
8581 assert . deepEqual (
@@ -89,10 +85,20 @@ test('definitions', () => {
8985 )
9086
9187 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+ ) ,
9591 null ,
9692 'should not return something for a missing identifier'
9793 )
9894} )
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