Skip to content

Commit b886ed2

Browse files
committed
Use Node test runner
1 parent e4654eb commit b886ed2

File tree

4 files changed

+46
-49
lines changed

4 files changed

+46
-49
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ jobs:
1717
strategy:
1818
matrix:
1919
node:
20-
- lts/fermium
20+
- lts/gallium
2121
- node

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,14 @@
4848
"@types/xast": "^1.0.0"
4949
},
5050
"devDependencies": {
51-
"@types/tape": "^4.0.0",
51+
"@types/node": "^18.0.0",
5252
"c8": "^7.0.0",
5353
"esast-util-from-js": "^1.0.0",
5454
"estree-util-build-jsx": "^2.0.0",
5555
"estree-util-to-js": "^1.0.0",
5656
"prettier": "^2.0.0",
5757
"remark-cli": "^11.0.0",
5858
"remark-preset-wooorm": "^9.0.0",
59-
"tape": "^5.0.0",
6059
"tsd": "^0.25.0",
6160
"type-coverage": "^2.0.0",
6261
"typescript": "^4.0.0",

test/core.js

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
import test from 'tape'
1+
import assert from 'node:assert/strict'
2+
import test from 'node:test'
23
import {x} from '../index.js'
34

4-
test('xastscript', (t) => {
5-
t.equal(typeof x, 'function', 'should expose a function')
5+
test('xastscript', () => {
6+
assert.equal(typeof x, 'function', 'should expose a function')
67

7-
t.deepEqual(
8+
assert.deepEqual(
89
x(),
910
{type: 'root', children: []},
1011
'should create a root when w/o `name`'
1112
)
1213

13-
t.throws(
14+
assert.throws(
1415
() => {
1516
// @ts-expect-error runtime.
1617
x(1)
@@ -19,31 +20,31 @@ test('xastscript', (t) => {
1920
'should throw w/ incorrect `name`'
2021
)
2122

22-
t.deepEqual(
23+
assert.deepEqual(
2324
x('y'),
2425
{type: 'element', name: 'y', attributes: {}, children: []},
2526
'should create an element when given `name`'
2627
)
2728

28-
t.deepEqual(
29+
assert.deepEqual(
2930
x('Y'),
3031
{type: 'element', name: 'Y', attributes: {}, children: []},
3132
'should treat `name` case-sensitive'
3233
)
3334

34-
t.deepEqual(
35+
assert.deepEqual(
3536
x('y', {a: 'b'}),
3637
{type: 'element', name: 'y', attributes: {a: 'b'}, children: []},
3738
'should create an element with given attributes'
3839
)
3940

40-
t.deepEqual(
41+
assert.deepEqual(
4142
x('y', {a: null, b: undefined, c: Number.NaN}),
4243
{type: 'element', name: 'y', attributes: {}, children: []},
4344
'should ignore null, undefined, and NaN attribute values'
4445
)
4546

46-
t.deepEqual(
47+
assert.deepEqual(
4748
x('y', {}, x('z')),
4849
{
4950
type: 'element',
@@ -54,7 +55,7 @@ test('xastscript', (t) => {
5455
'should add a child'
5556
)
5657

57-
t.deepEqual(
58+
assert.deepEqual(
5859
x('y', {}, [x('a'), x('b')]),
5960
{
6061
type: 'element',
@@ -68,7 +69,7 @@ test('xastscript', (t) => {
6869
'should add children as an array'
6970
)
7071

71-
t.deepEqual(
72+
assert.deepEqual(
7273
// @ts-expect-error Deeply nested children are not typed.
7374
x('y', {}, [[[x('a')]], [[[[x('b')]], x('c')]]]),
7475
{
@@ -84,7 +85,7 @@ test('xastscript', (t) => {
8485
'should add children in a deeply nested array'
8586
)
8687

87-
t.deepEqual(
88+
assert.deepEqual(
8889
x('y', {}, x('a'), x('b')),
8990
{
9091
type: 'element',
@@ -98,7 +99,7 @@ test('xastscript', (t) => {
9899
'should add children as arguments'
99100
)
100101

101-
t.deepEqual(
102+
assert.deepEqual(
102103
x('y', {}, 'a', 1),
103104
{
104105
type: 'element',
@@ -112,13 +113,13 @@ test('xastscript', (t) => {
112113
'should add strings and numbers as literals'
113114
)
114115

115-
t.deepEqual(
116+
assert.deepEqual(
116117
x('y', {}, null, undefined),
117118
{type: 'element', name: 'y', attributes: {}, children: []},
118119
'should ignore null and undefined children'
119120
)
120121

121-
t.throws(
122+
assert.throws(
122123
() => {
123124
// @ts-expect-error runtime.
124125
x('y', {}, {})
@@ -127,7 +128,7 @@ test('xastscript', (t) => {
127128
'should throw on invalid children'
128129
)
129130

130-
t.deepEqual(
131+
assert.deepEqual(
131132
x('y', 'z'),
132133
{
133134
type: 'element',
@@ -138,7 +139,7 @@ test('xastscript', (t) => {
138139
'should support omitting attributes when given a string for a child'
139140
)
140141

141-
t.deepEqual(
142+
assert.deepEqual(
142143
x('y', 1),
143144
{
144145
type: 'element',
@@ -149,7 +150,7 @@ test('xastscript', (t) => {
149150
'should support omitting attributes when given a number for a child'
150151
)
151152

152-
t.deepEqual(
153+
assert.deepEqual(
153154
x('y', ['a', 1]),
154155
{
155156
type: 'element',
@@ -163,19 +164,19 @@ test('xastscript', (t) => {
163164
'should support omitting attributes when given an array for a child'
164165
)
165166

166-
t.deepEqual(
167+
assert.deepEqual(
167168
x(null, '1'),
168169
{type: 'root', children: [{type: 'text', value: '1'}]},
169170
'should create a root with a textual child'
170171
)
171172

172-
t.deepEqual(
173+
assert.deepEqual(
173174
x(null, 1),
174175
{type: 'root', children: [{type: 'text', value: '1'}]},
175176
'should create a root with a numerical child'
176177
)
177178

178-
t.deepEqual(
179+
assert.deepEqual(
179180
x(null, x('a')),
180181
{
181182
type: 'root',
@@ -184,7 +185,7 @@ test('xastscript', (t) => {
184185
'should create a root with a node child'
185186
)
186187

187-
t.deepEqual(
188+
assert.deepEqual(
188189
x('a', {}, [x(null, x('b'))]),
189190
{
190191
type: 'element',
@@ -194,6 +195,4 @@ test('xastscript', (t) => {
194195
},
195196
'should create a node w/ by unraveling roots'
196197
)
197-
198-
t.end()
199198
})

test/jsx.jsx

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,92 @@
11
/** @jsxImportSource xastscript */
22

3-
import test from 'tape'
3+
import assert from 'node:assert/strict'
4+
import test from 'node:test'
45
import {u} from 'unist-builder'
56
import {x} from '../index.js'
67

7-
test('name', (t) => {
8-
t.deepEqual(<a />, x('a'), 'should support a self-closing element')
8+
test('name', () => {
9+
assert.deepEqual(<a />, x('a'), 'should support a self-closing element')
910

10-
t.deepEqual(<a>b</a>, x('a', 'b'), 'should support a value as a child')
11+
assert.deepEqual(<a>b</a>, x('a', 'b'), 'should support a value as a child')
1112

1213
const A = 'a'
1314

1415
// Note: this file is a template, generated with different runtimes.
1516
// @ts-ignore: TS (depending on this build) sometimes doesn’t understand.
16-
t.deepEqual(<A />, x(A), 'should support an uppercase tag name')
17+
assert.deepEqual(<A />, x(A), 'should support an uppercase tag name')
1718

18-
t.deepEqual(
19+
assert.deepEqual(
1920
<a>{1 + 1}</a>,
2021
x('a', '2'),
2122
'should support expressions as children'
2223
)
2324

24-
t.deepEqual(<></>, u('root', []), 'should support a fragment')
25+
assert.deepEqual(<></>, u('root', []), 'should support a fragment')
2526

26-
t.deepEqual(
27+
assert.deepEqual(
2728
<>a</>,
2829
u('root', [u('text', 'a')]),
2930
'should support a fragment with text'
3031
)
3132

32-
t.deepEqual(
33+
assert.deepEqual(
3334
<>
3435
<a />
3536
</>,
3637
u('root', [x('a')]),
3738
'should support a fragment with an element'
3839
)
3940

40-
t.deepEqual(
41+
assert.deepEqual(
4142
<>{-1}</>,
4243
u('root', [u('text', '-1')]),
4344
'should support a fragment with an expression'
4445
)
4546

4647
const com = {acme: {a: 'A', b: 'B'}}
4748

48-
t.deepEqual(
49+
assert.deepEqual(
4950
// Note: this file is a template, generated with different runtimes.
5051
// @ts-ignore: TS (depending on this build) sometimes doesn’t understand.
5152
<com.acme.a />,
5253
x(com.acme.a),
5354
'should support members as names (`a.b`)'
5455
)
5556

56-
t.deepEqual(
57+
assert.deepEqual(
5758
<a b />,
5859
x('a', {b: 'true'}),
5960
'should support a boolean attribute'
6061
)
6162

62-
t.deepEqual(
63+
assert.deepEqual(
6364
<a b="" />,
6465
x('a', {b: ''}),
6566
'should support a double quoted attribute'
6667
)
6768

68-
t.deepEqual(
69+
assert.deepEqual(
6970
<a b='"' />,
7071
x('a', {b: '"'}),
7172
'should support a single quoted attribute'
7273
)
7374

74-
t.deepEqual(
75+
assert.deepEqual(
7576
<a b={1 + 1} />,
7677
x('a', {b: '2'}),
7778
'should support expression value attributes'
7879
)
7980

8081
const props = {a: 1, b: 2}
8182

82-
t.deepEqual(
83+
assert.deepEqual(
8384
<a {...props} />,
8485
x('a', props),
8586
'should support expression spread attributes'
8687
)
8788

88-
t.deepEqual(
89+
assert.deepEqual(
8990
<a>
9091
<b />c<d>e</d>
9192
{1 + 1}
@@ -94,7 +95,7 @@ test('name', (t) => {
9495
'should support text, elements, and expressions in JSX'
9596
)
9697

97-
t.deepEqual(
98+
assert.deepEqual(
9899
<a>
99100
<>{1}</>
100101
</a>,
@@ -107,7 +108,7 @@ test('name', (t) => {
107108
['Chrome', 'A chemical element.']
108109
]
109110

110-
t.deepEqual(
111+
assert.deepEqual(
111112
<dl>
112113
{dl.map(([title, definition]) => (
113114
<>
@@ -124,6 +125,4 @@ test('name', (t) => {
124125
]),
125126
'should support a fragment in an element (#2)'
126127
)
127-
128-
t.end()
129128
})

0 commit comments

Comments
 (0)