|
1 | 1 | import assert from 'node:assert/strict'
|
2 |
| -import test from 'tape' |
| 2 | +import test from 'node:test' |
3 | 3 | import {fromMarkdown} from 'mdast-util-from-markdown'
|
4 | 4 | import {find} from 'unist-util-find'
|
5 | 5 |
|
6 |
| -test('find', function (t) { |
| 6 | +test('find', async function (t) { |
7 | 7 | const tree = fromMarkdown('Some _emphasis_, **strongness**, and `code`.')
|
8 | 8 | assert(tree.type === 'root')
|
9 | 9 | const paragraph = tree.children[0]
|
10 | 10 | assert(paragraph.type === 'paragraph')
|
11 | 11 |
|
12 |
| - t.throws(function () { |
13 |
| - // @ts-expect-error: check that an error is thrown at runtime. |
14 |
| - find() |
15 |
| - }, 'should fail without tree') |
| 12 | + await t.test('should fail without tree', function () { |
| 13 | + assert.throws(function () { |
| 14 | + // @ts-expect-error: check that an error is thrown at runtime. |
| 15 | + find() |
| 16 | + }) |
| 17 | + }) |
16 | 18 |
|
17 |
| - t.throws(function () { |
18 |
| - // @ts-expect-error: check that an error is thrown at runtime. |
19 |
| - find(tree) |
20 |
| - }, 'should fail without condition') |
| 19 | + await t.test('should fail without condition', function () { |
| 20 | + assert.throws(function () { |
| 21 | + // @ts-expect-error: check that an error is thrown at runtime. |
| 22 | + find(tree) |
| 23 | + }) |
| 24 | + }) |
21 | 25 |
|
22 |
| - t.test('should find with string condition', function (st) { |
| 26 | + await t.test('should find with string condition', function () { |
23 | 27 | const result = find(tree, 'value')
|
24 | 28 |
|
25 |
| - st.equal(result, paragraph.children[0]) |
26 |
| - |
27 |
| - st.end() |
| 29 | + assert.equal(result, paragraph.children[0]) |
28 | 30 | })
|
29 | 31 |
|
30 |
| - t.test('should find with object condition', function (st) { |
| 32 | + await t.test('should find with object condition', function () { |
31 | 33 | const result = find(tree, {type: 'emphasis'})
|
32 | 34 |
|
33 |
| - st.equal(result, paragraph.children[1]) |
34 |
| - |
35 |
| - st.end() |
| 35 | + assert.equal(result, paragraph.children[1]) |
36 | 36 | })
|
37 | 37 |
|
38 |
| - t.test('should find with function condition', function (st) { |
| 38 | + await t.test('should find with function condition', function () { |
39 | 39 | const result = find(tree, function (node) {
|
40 | 40 | return node.type === 'inlineCode'
|
41 | 41 | })
|
42 | 42 |
|
43 |
| - st.equal(result, paragraph.children[5]) |
44 |
| - |
45 |
| - st.end() |
| 43 | + assert.equal(result, paragraph.children[5]) |
46 | 44 | })
|
47 | 45 |
|
48 |
| - t.test('should return undefined if no matches', function (st) { |
| 46 | + await t.test('should return undefined if no matches', function () { |
49 | 47 | const result = find(tree, 'nope, nope, nope')
|
50 | 48 |
|
51 |
| - st.equal(result, undefined) |
52 |
| - |
53 |
| - st.end() |
| 49 | + assert.equal(result, undefined) |
54 | 50 | })
|
55 | 51 | })
|
0 commit comments