Skip to content

Commit 4bf05a3

Browse files
committed
Update tests for changes in @types/unist
1 parent 48d4b27 commit 4bf05a3

File tree

2 files changed

+35
-16
lines changed

2 files changed

+35
-16
lines changed

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import {arrayIterate} from 'array-iterate'
2-
31
/**
42
* @typedef {import('unist').Parent} Parent
53
* @typedef {import('unist').Node} Node
@@ -15,6 +13,8 @@ import {arrayIterate} from 'array-iterate'
1513
* @returns {void}
1614
*/
1715

16+
import {arrayIterate} from 'array-iterate'
17+
1818
/**
1919
* Turn `callback` into a child-modifier accepting a parent.
2020
* See `array-iterate` for more info.

test.js

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* @typedef {import('unist').Literal<number>} ExampleLiteral
3+
* @typedef {import('unist').Parent<ExampleLiteral>} ExampleParent
4+
*/
5+
16
import test from 'tape'
27
import {modifyChildren} from './index.js'
38

@@ -6,7 +11,7 @@ function noop() {}
611
test('modifyChildren()', function (t) {
712
t.throws(
813
function () {
9-
// @ts-ignore runtime.
14+
// @ts-expect-error runtime.
1015
modifyChildren(noop)()
1116
},
1217
/Missing children in `parent`/,
@@ -15,7 +20,7 @@ test('modifyChildren()', function (t) {
1520

1621
t.throws(
1722
function () {
18-
// @ts-ignore runtime.
23+
// @ts-expect-error runtime.
1924
modifyChildren(noop)({})
2025
},
2126
/Missing children in `parent`/,
@@ -54,7 +59,11 @@ test('modifyChildren()', function (t) {
5459
]
5560
var n = -1
5661

57-
modifyChildren(function (child, index, parent) {
62+
modifyChildren(function (
63+
/** @type {ExampleLiteral} */ child,
64+
index,
65+
/** @type {ExampleParent} */ parent
66+
) {
5867
n++
5968

6069
if (index < 3) {
@@ -63,15 +72,17 @@ test('modifyChildren()', function (t) {
6372

6473
st.deepEqual(child, children[n])
6574
st.deepEqual(index, n)
66-
})({
67-
type: 'y',
68-
children: [
69-
{type: 'x', value: 0},
70-
{type: 'x', value: 1},
71-
{type: 'x', value: 2},
72-
{type: 'x', value: 3}
73-
]
74-
})
75+
})(
76+
/** @type {ExampleParent} */ ({
77+
type: 'y',
78+
children: [
79+
{type: 'x', value: 0},
80+
{type: 'x', value: 1},
81+
{type: 'x', value: 2},
82+
{type: 'x', value: 3}
83+
]
84+
})
85+
)
7586

7687
st.end()
7788
})
@@ -93,7 +104,11 @@ test('modifyChildren()', function (t) {
93104
]
94105
}
95106

96-
modifyChildren(function (child, index, parent) {
107+
modifyChildren(function (
108+
/** @type {ExampleLiteral} */ child,
109+
index,
110+
/** @type {ExampleParent} */ parent
111+
) {
97112
st.deepEqual(child, children[++n])
98113

99114
if (child.value === 1) {
@@ -129,7 +144,11 @@ test('modifyChildren()', function (t) {
129144
}
130145
var inserted = false
131146

132-
modifyChildren(function (child, _, parent) {
147+
modifyChildren(function (
148+
/** @type {ExampleLiteral} */ child,
149+
_,
150+
/** @type {ExampleParent} */ parent
151+
) {
133152
st.deepEqual(child, calls[++n])
134153

135154
if (!inserted && child.value === 1) {

0 commit comments

Comments
 (0)