Skip to content

Commit b2747fb

Browse files
committed
Use Node test runner
1 parent 9d41eda commit b2747fb

17 files changed

+128
-144
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
@@ -40,12 +40,11 @@
4040
"zwitch": "^2.0.0"
4141
},
4242
"devDependencies": {
43-
"@types/tape": "^4.0.0",
43+
"@types/node": "^18.0.0",
4444
"c8": "^7.0.0",
4545
"prettier": "^2.0.0",
4646
"remark-cli": "^11.0.0",
4747
"remark-preset-wooorm": "^9.0.0",
48-
"tape": "^5.0.0",
4948
"tsd": "^0.25.0",
5049
"type-coverage": "^2.0.0",
5150
"typescript": "^4.0.0",

test/children.js

Lines changed: 7 additions & 8 deletions
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',
@@ -32,6 +33,4 @@ test('children', (t) => {
3233
/node should be an object: `'one'` in `{ type: 'bar', children: \[ 'one' ] }`$/,
3334
'should throw on invalid descendants'
3435
)
35-
36-
t.end()
3736
})

test/code.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,41 @@
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(code)', (t) => {
5-
t.throws(
5+
test('assert(code)', () => {
6+
nodeAssert.throws(
67
() => {
78
assert({type: 'code'})
89
},
910
/literal should have `value`: `{ type: 'code' }`$/,
1011
'should throw if `code` is not a text'
1112
)
1213

13-
t.doesNotThrow(() => {
14+
nodeAssert.doesNotThrow(() => {
1415
assert({type: 'code', value: ''})
1516
}, 'should not throw if `code` has no extra properties')
1617

17-
t.throws(
18+
nodeAssert.throws(
1819
() => {
1920
assert({type: 'code', lang: 0, value: ''})
2021
},
2122
/`lang` must be `string`: `{ type: 'code', lang: 0, value: '' }`$/,
2223
'should throw if `lang` is not a string'
2324
)
2425

25-
t.throws(
26+
nodeAssert.throws(
2627
() => {
2728
assert({type: 'code', lang: 'js', meta: 1, value: ''})
2829
},
2930
/`meta` must be `string`: `{ type: 'code', lang: 'js', meta: 1, value: '' }`$/,
3031
'should throw if `meta` is not a string'
3132
)
3233

33-
t.throws(
34+
nodeAssert.throws(
3435
() => {
3536
assert({type: 'code', meta: '', value: ''})
3637
},
3738
/code with `meta` must also have `lang`: `{ type: 'code', meta: '', value: '' }`$/,
3839
'should throw if `meta` is defined but not `lang`'
3940
)
40-
41-
t.end()
4241
})

test/definition.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,57 @@
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(definition)', (t) => {
5-
t.throws(
5+
test('assert(definition)', () => {
6+
nodeAssert.throws(
67
() => {
78
assert({type: 'definition'})
89
},
910
/`identifier` must be `string`: `{ type: 'definition' }`$/,
1011
'should throw if `definition` has no `identifier`'
1112
)
1213

13-
t.throws(
14+
nodeAssert.throws(
1415
() => {
1516
assert({type: 'definition', identifier: '1'})
1617
},
1718
/`url` must be `string`: `{ type: 'definition', identifier: '1' }`$/,
1819
'should throw if `definition` has no `url`'
1920
)
2021

21-
t.throws(
22+
nodeAssert.throws(
2223
() => {
2324
assert({type: 'definition', identifier: 1})
2425
},
2526
/`identifier` must be `string`: `{ type: 'definition', identifier: 1 }`$/,
2627
'should throw if `identifier` is not a `string`'
2728
)
2829

29-
t.throws(
30+
nodeAssert.throws(
3031
() => {
3132
assert({type: 'definition', url: 1})
3233
},
3334
/`identifier` must be `string`: `{ type: 'definition', url: 1 }`$/,
3435
'should throw if `url` is not a `string`'
3536
)
3637

37-
t.doesNotThrow(() => {
38+
nodeAssert.doesNotThrow(() => {
3839
assert({type: 'definition', identifier: '1', url: '1'})
3940
}, 'should not throw if `definition` has no other properties')
4041

41-
t.throws(
42+
nodeAssert.throws(
4243
() => {
4344
assert({type: 'definition', identifier: '1', url: '1', title: 1})
4445
},
4546
/`title` must be `string`: `{ type: 'definition', identifier: '1', url: '1', title: 1 }`$/,
4647
'should throw if `title` is not a `string`'
4748
)
4849

49-
t.throws(
50+
nodeAssert.throws(
5051
() => {
5152
assert({type: 'definition', identifier: '1', url: '1', label: 1})
5253
},
5354
/`label` must be `string`: `{ type: 'definition', identifier: '1', url: '1', label: 1 }`$/,
5455
'should throw if `label` is not a `string`'
5556
)
56-
57-
t.end()
5857
})

test/footnote-definition.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +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('assert(footnoteDefinition)', (t) => {
5-
t.throws(
5+
test('assert(footnoteDefinition)', () => {
6+
nodeAssert.throws(
67
() => {
78
assert({type: 'footnoteDefinition'})
89
},
910
/parent should have `children`: `{ type: 'footnoteDefinition' }`$/,
1011
'should throw if `footnoteDefinition` is not a parent'
1112
)
1213

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

21-
t.throws(
22+
nodeAssert.throws(
2223
() => {
2324
assert({type: 'footnoteDefinition', identifier: 1, children: []})
2425
},
2526
/`footnoteDefinition` must have `identifier`: `{ type: 'footnoteDefinition', identifier: 1, children: \[] }`$/,
2627
'should throw if `identifier` is not a `string`'
2728
)
2829

29-
t.doesNotThrow(() => {
30+
nodeAssert.doesNotThrow(() => {
3031
assert({type: 'footnoteDefinition', identifier: '1', children: []})
3132
}, 'should not throw if `footnoteDefinition` has an identifier')
3233

33-
t.throws(
34+
nodeAssert.throws(
3435
() => {
3536
assert({
3637
type: 'footnoteDefinition',
@@ -42,6 +43,4 @@ test('assert(footnoteDefinition)', (t) => {
4243
/`label` must be `string`: `{ type: 'footnoteDefinition',\s+identifier: '1',\s+label: 1,\s+children: \[] }`$/,
4344
'should throw if `label` is not a `string`'
4445
)
45-
46-
t.end()
4746
})

test/footnote-reference.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,33 @@
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(footnoteReference)', (t) => {
5-
t.throws(
5+
test('assert(footnoteReference)', () => {
6+
nodeAssert.throws(
67
() => {
78
assert({type: 'footnoteReference'})
89
},
910
/`identifier` must be `string`: `{ type: 'footnoteReference' }`$/,
1011
'should throw if `footnoteReference` has no `identifier`'
1112
)
1213

13-
t.throws(
14+
nodeAssert.throws(
1415
() => {
1516
assert({type: 'footnoteReference', identifier: 1})
1617
},
1718
/`identifier` must be `string`: `{ type: 'footnoteReference', identifier: 1 }`$/,
1819
'should throw if `identifier` is not a `string`'
1920
)
2021

21-
t.doesNotThrow(() => {
22+
nodeAssert.doesNotThrow(() => {
2223
assert({type: 'footnoteReference', identifier: '1'})
2324
}, 'should not throw if `footnoteReference` has no other properties')
2425

25-
t.throws(
26+
nodeAssert.throws(
2627
() => {
2728
assert({type: 'footnoteReference', identifier: '1', label: 1})
2829
},
2930
/`label` must be `string`: `{ type: 'footnoteReference', identifier: '1', label: 1 }`$/,
3031
'should throw if `label` is not a `string`'
3132
)
32-
33-
t.end()
3433
})

test/heading.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,33 @@
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(heading)', (t) => {
5-
t.throws(
5+
test('assert(heading)', () => {
6+
nodeAssert.throws(
67
() => {
78
assert({type: 'heading'})
89
},
910
/parent should have `children`: `{ type: 'heading' }`$/,
1011
'should throw if a `heading` is not a parent'
1112
)
1213

13-
t.throws(
14+
nodeAssert.throws(
1415
() => {
1516
assert({type: 'heading', depth: 0, children: []})
1617
},
1718
/`depth` should be gte `1`: `{ type: 'heading', depth: 0, children: \[] }`$/,
1819
'should throw if `depth` is lower than 1'
1920
)
2021

21-
t.throws(
22+
nodeAssert.throws(
2223
() => {
2324
assert({type: 'heading', depth: 7, children: []})
2425
},
2526
/`depth` should be lte `6`: `{ type: 'heading', depth: 7, children: \[] }`$/,
2627
'should throw if `depth` is lower than 7'
2728
)
2829

29-
t.doesNotThrow(() => {
30+
nodeAssert.doesNotThrow(() => {
3031
assert({type: 'heading', depth: 1, children: []})
3132
}, 'should not throw if `heading` is between 0 and 7')
32-
33-
t.end()
3433
})

test/image-reference.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,57 @@
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(imageReference)', (t) => {
5-
t.throws(
5+
test('assert(imageReference)', () => {
6+
nodeAssert.throws(
67
() => {
78
assert({type: 'imageReference'})
89
},
910
/`identifier` must be `string`: `{ type: 'imageReference' }`$/,
1011
'should throw if `imageReference` has no `identifier`'
1112
)
1213

13-
t.throws(
14+
nodeAssert.throws(
1415
() => {
1516
assert({type: 'imageReference', identifier: 1})
1617
},
1718
/`identifier` must be `string`: `{ type: 'imageReference', identifier: 1 }`$/,
1819
'should throw if `identifier` is not a `string`'
1920
)
2021

21-
t.doesNotThrow(() => {
22+
nodeAssert.doesNotThrow(() => {
2223
assert({type: 'imageReference', identifier: '1'})
2324
}, 'should not throw if `imageReference` has no other properties')
2425

25-
t.throws(
26+
nodeAssert.throws(
2627
() => {
2728
assert({type: 'imageReference', identifier: '1', alt: 1})
2829
},
2930
/`alt` must be `string`: `{ type: 'imageReference', identifier: '1', alt: 1 }`$/,
3031
'should throw if `alt` is not a `string`'
3132
)
3233

33-
t.throws(
34+
nodeAssert.throws(
3435
() => {
3536
assert({type: 'imageReference', identifier: '1', referenceType: 1})
3637
},
3738
/`referenceType` must be `shortcut`, `collapsed`, or `full`: `{ type: 'imageReference', identifier: '1', referenceType: 1 }`$/,
3839
'should throw if `referenceType` is not a `string`'
3940
)
4041

41-
t.doesNotThrow(() => {
42+
nodeAssert.doesNotThrow(() => {
4243
assert({
4344
type: 'imageReference',
4445
identifier: '1',
4546
referenceType: 'collapsed'
4647
})
4748
}, 'should not throw if `referenceType` is valid')
4849

49-
t.throws(
50+
nodeAssert.throws(
5051
() => {
5152
assert({type: 'imageReference', identifier: '1', label: 1})
5253
},
5354
/`label` must be `string`: `{ type: 'imageReference', identifier: '1', label: 1 }`$/,
5455
'should throw if `label` is not a `string`'
5556
)
56-
57-
t.end()
5857
})

0 commit comments

Comments
 (0)