Skip to content

Commit 8ee35ee

Browse files
committed
Use Node test runner
1 parent 8543244 commit 8ee35ee

File tree

10 files changed

+46
-55
lines changed

10 files changed

+46
-55
lines changed

.github/workflows/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ jobs:
1717
strategy:
1818
matrix:
1919
node:
20-
- lts/fermium
20+
- lts/hydrogen
2121
- node

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,11 @@
3939
"zwitch": "^2.0.0"
4040
},
4141
"devDependencies": {
42-
"@types/tape": "^4.0.0",
42+
"@types/node": "^18.0.0",
4343
"c8": "^7.0.0",
4444
"prettier": "^2.0.0",
4545
"remark-cli": "^11.0.0",
4646
"remark-preset-wooorm": "^9.0.0",
47-
"tape": "^5.0.0",
4847
"tsd": "^0.25.0",
4948
"type-coverage": "^2.0.0",
5049
"typescript": "^4.0.0",

test/children.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
1-
import test from 'tape'
1+
import nodeAssert from 'node:assert/strict'
2+
import test from 'node:test'
23
import {assert} from '../index.js'
34

4-
test('children', (t) => {
5-
t.throws(
5+
test('children', () => {
6+
nodeAssert.throws(
67
() => {
78
assert({type: 'paragraph', children: {alpha: 'bravo'}})
89
},
910
/`children` should be an array: `{ type: 'paragraph', children: { alpha: 'bravo' } }`$/,
1011
'should throw if given a non-node child in children'
1112
)
1213

13-
t.throws(
14+
nodeAssert.throws(
1415
() => {
1516
assert({type: 'paragraph', children: ['one']})
1617
},
1718
/node should be an object: `'one'` in `{ type: 'paragraph', children: \[ 'one' ] }`$/,
1819
'should throw if given a non-node child in children'
1920
)
2021

21-
t.doesNotThrow(() => {
22+
nodeAssert.doesNotThrow(() => {
2223
assert({type: 'paragraph', children: [{type: 'text', value: 'alpha'}]})
2324
}, 'should not throw on vald children')
2425

25-
t.throws(
26+
nodeAssert.throws(
2627
() => {
2728
assert({
2829
type: 'paragraph',
@@ -37,6 +38,4 @@ test('children', (t) => {
3738
/node should be an object: `'one'` in `{ type: 'bar', children: \[ 'one' ] }`$/,
3839
'should throw on invalid descendants'
3940
)
40-
41-
t.end()
4241
})

test/comment.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
import test from 'tape'
1+
import nodeAssert from 'node:assert/strict'
2+
import test from 'node:test'
23
import {assert} from '../index.js'
34

4-
test('assert(comment)', (t) => {
5-
t.throws(
5+
test('assert(comment)', () => {
6+
nodeAssert.throws(
67
() => {
78
assert({type: 'comment'})
89
},
910
/literal should have `value`: `{ type: 'comment' }`$/,
1011
'should throw if a `comment` doesn’t have a value'
1112
)
1213

13-
t.doesNotThrow(() => {
14+
nodeAssert.doesNotThrow(() => {
1415
assert({type: 'comment', value: 'Alpha'})
1516
}, 'should allow `value`')
16-
17-
t.end()
1817
})

test/doctype.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import test from 'tape'
1+
import nodeAssert from 'node:assert/strict'
2+
import test from 'node:test'
23
import {assert} from '../index.js'
34

4-
test('assert(doctype)', (t) => {
5-
t.doesNotThrow(() => {
5+
test('assert(doctype)', () => {
6+
nodeAssert.doesNotThrow(() => {
67
assert({type: 'doctype'})
78
}, 'should allow doctypes')
8-
9-
t.end()
109
})

test/element.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
1-
import test from 'tape'
1+
import nodeAssert from 'node:assert/strict'
2+
import test from 'node:test'
23
import {assert} from '../index.js'
34

4-
test('assert(element)', (t) => {
5-
t.throws(
5+
test('assert(element)', () => {
6+
nodeAssert.throws(
67
() => {
78
assert({type: 'element'})
89
},
910
/parent should have `children`: `{ type: 'element' }`$/,
1011
'should throw if a `element` is not a parent'
1112
)
1213

13-
t.throws(
14+
nodeAssert.throws(
1415
() => {
1516
assert({type: 'element', children: []})
1617
},
1718
/`element` should have a `tagName`: `{ type: 'element', children: \[] }`$/,
1819
'should throw if a `element` has no `tagName`'
1920
)
2021

21-
t.throws(
22+
nodeAssert.throws(
2223
() => {
2324
assert({type: 'element', tagName: '', children: []})
2425
},
2526
/`element.tagName` should not be empty: `{ type: 'element', tagName: '', children: \[] }`$/,
2627
'should throw if a `element` has an empty `tagName`'
2728
)
28-
29-
t.end()
3029
})

test/node.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,37 @@
1-
import test from 'tape'
1+
import nodeAssert from 'node:assert/strict'
2+
import test from 'node:test'
23
import {assert} from '../index.js'
34

4-
test('node', (t) => {
5-
t.throws(
5+
test('node', () => {
6+
nodeAssert.throws(
67
() => {
78
assert()
89
},
910
/node should be an object: `undefined`$/,
1011
'should throw if not given a node (#1)'
1112
)
1213

13-
t.throws(
14+
nodeAssert.throws(
1415
() => {
1516
assert(null)
1617
},
1718
/node should be an object: `null`$/,
1819
'should throw if not given a node (#2)'
1920
)
2021

21-
t.throws(
22+
nodeAssert.throws(
2223
() => {
2324
assert('foo')
2425
},
2526
/node should be an object: `'foo'`$/,
2627
'should throw if given a non-node (#1)'
2728
)
2829

29-
t.throws(
30+
nodeAssert.throws(
3031
() => {
3132
assert(6)
3233
},
3334
/node should be an object: `6`$/,
3435
'should throw if not given a non-node (#2)'
3536
)
36-
37-
t.end()
3837
})

test/parent.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
import test from 'tape'
1+
import nodeAssert from 'node:assert/strict'
2+
import test from 'node:test'
23
import {parent} from '../index.js'
34

4-
test('parent', (t) => {
5-
t.throws(
5+
test('parent', () => {
6+
nodeAssert.throws(
67
() => {
78
parent()
89
},
910
/node should be an object: `undefined`$/,
1011
'should throw if not given a node'
1112
)
1213

13-
t.throws(
14+
nodeAssert.throws(
1415
() => {
1516
parent({type: 'x'})
1617
},
1718
/parent should have `children`/,
1819
'should throw if not given a parent'
1920
)
20-
21-
t.end()
2221
})

test/root.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
import test from 'tape'
1+
import nodeAssert from 'node:assert/strict'
2+
import test from 'node:test'
23
import {assert} from '../index.js'
34

4-
test('assert(root)', (t) => {
5-
t.throws(
5+
test('assert(root)', () => {
6+
nodeAssert.throws(
67
() => {
78
assert({type: 'root'})
89
},
910
/parent should have `children`: `{ type: 'root' }`$/,
1011
'should throw if a `root` is not a parent'
1112
)
1213

13-
t.throws(
14+
nodeAssert.throws(
1415
() => {
1516
assert({type: 'root', children: [{type: 'root', children: []}]})
1617
},
1718
/`root` should not have a parent: `{ type: 'root', children: \[] }` in `{ type: 'root', children: \[ { type: 'root', children: \[] } ] }`$/,
1819
'should throw if a `root` has a parent'
1920
)
20-
21-
t.end()
2221
})

test/text.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
import test from 'tape'
1+
import nodeAssert from 'node:assert/strict'
2+
import test from 'node:test'
23
import {assert} from '../index.js'
34

4-
test('assert(text)', (t) => {
5-
t.throws(
5+
test('assert(text)', () => {
6+
nodeAssert.throws(
67
() => {
78
assert({type: 'text'})
89
},
910
/literal should have `value`: `{ type: 'text' }`$/,
1011
'should throw if a `text` doesn’t have a value'
1112
)
1213

13-
t.doesNotThrow(() => {
14+
nodeAssert.doesNotThrow(() => {
1415
assert({type: 'text', value: 'Alpha'})
1516
}, 'should allow `value`')
16-
17-
t.end()
1817
})

0 commit comments

Comments
 (0)