Skip to content

Commit 39273c7

Browse files
committed
Use Node test runner
1 parent b0889ea commit 39273c7

File tree

11 files changed

+78
-88
lines changed

11 files changed

+78
-88
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/hydrogen
2121
- node

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,11 @@
4444
"@types/unist": "^2.0.0"
4545
},
4646
"devDependencies": {
47-
"@types/tape": "^4.0.0",
47+
"@types/node": "^18.0.0",
4848
"c8": "^7.0.0",
4949
"prettier": "^2.0.0",
5050
"remark-cli": "^11.0.0",
5151
"remark-preset-wooorm": "^9.0.0",
52-
"tape": "^5.0.0",
5352
"tsd": "^0.25.0",
5453
"type-coverage": "^2.0.0",
5554
"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: 'foo', children: {alpha: 'bravo'}})
89
},
910
/`children` should be an array: `{ type: 'foo', 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: 'foo', children: ['one']})
1617
},
1718
/node should be an object: `'one'` in `{ type: 'foo', children: \[ 'one' ] }`$/,
1819
'should throw if given a non-node child in children'
1920
)
2021

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

25-
t.throws(
26+
nodeAssert.throws(
2627
() => {
2728
assert({
2829
type: 'foo',
@@ -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/literal.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 assert from 'node:assert/strict'
2+
import test from 'node:test'
23
import {literal} from '../index.js'
34

4-
test('literal()', (t) => {
5-
t.throws(
5+
test('literal()', () => {
6+
assert.throws(
67
() => {
78
literal({})
89
},
910
/node should have a type: `{}`$/,
1011
'should throw the same errors as `assert()`'
1112
)
1213

13-
t.throws(
14+
assert.throws(
1415
() => {
1516
literal({type: 'strong', children: []})
1617
},
1718
/literal should not have `children`: `{ type: 'strong', children: \[] }`$/,
1819
'should throw if the given node has `children`'
1920
)
2021

21-
t.throws(
22+
assert.throws(
2223
() => {
2324
literal({type: 'break'})
2425
},
2526
/literal should have `value`: `{ type: 'break' }`$/,
2627
'should throw if the given node has no `value`'
2728
)
2829

29-
t.doesNotThrow(() => {
30+
assert.doesNotThrow(() => {
3031
literal({type: 'text', value: 'foo'})
3132
}, 'should not throw on valid text nodes')
32-
33-
t.end()
3433
})

test/node.js

Lines changed: 7 additions & 8 deletions
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/non-defined.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +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('non-defined', (t) => {
5-
t.doesNotThrow(() => {
5+
test('non-defined', () => {
6+
nodeAssert.doesNotThrow(() => {
67
assert({
78
type: 'element',
89
properties: {
@@ -17,7 +18,7 @@ test('non-defined', (t) => {
1718
})
1819
}, 'should not throw if non-defined properties are found')
1920

20-
t.throws(
21+
nodeAssert.throws(
2122
() => {
2223
assert({
2324
type: 'break',
@@ -27,6 +28,4 @@ test('non-defined', (t) => {
2728
/non-specced property `data` should be JSON: `{ type: 'break', data: { foo: \[Function: Function] } }`$/,
2829
'should throw if non-defined properties are not serialisable'
2930
)
30-
31-
t.end()
3231
})

test/parent.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 assert 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+
assert.throws(
67
() => {
78
parent({})
89
},
910
/node should have a type: `{}`$/,
1011
'should throw the same errors as `assert()`'
1112
)
1213

13-
t.throws(
14+
assert.throws(
1415
() => {
1516
parent({type: 'text', value: 'foo'})
1617
},
1718
/parent should not have `value`: `{ type: 'text', value: 'foo' }`$/,
1819
'should throw if the given node has a `value`'
1920
)
2021

21-
t.throws(
22+
assert.throws(
2223
() => {
2324
parent({type: 'break'})
2425
},
2526
/parent should have `children`: `{ type: 'break' }`$/,
2627
'should throw if the given node has `children`'
2728
)
2829

29-
t.doesNotThrow(() => {
30+
assert.doesNotThrow(() => {
3031
parent({type: 'strong', children: []})
3132
}, 'should not throw on valid void nodes')
32-
33-
t.end()
3433
})

test/position.js

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,101 @@
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('position', (t) => {
5-
t.throws(
5+
test('position', () => {
6+
nodeAssert.throws(
67
() => {
78
assert({type: 'foo', position: 1})
89
},
910
/`position` should be an object: `{ type: 'foo', position: 1 }`$/,
1011
'should throw if given a non-object `position`'
1112
)
1213

13-
t.doesNotThrow(() => {
14+
nodeAssert.doesNotThrow(() => {
1415
assert({type: 'foo', position: null})
1516
}, 'should not throw if given a null `position`')
1617

17-
t.doesNotThrow(() => {
18+
nodeAssert.doesNotThrow(() => {
1819
assert({type: 'foo', position: {}})
1920
}, 'should not throw if given an empty `position` object')
2021

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

29-
t.doesNotThrow(() => {
30+
nodeAssert.doesNotThrow(() => {
3031
assert({type: 'foo', position: {start: null}})
3132
}, 'should not throw if given a null `position.start`')
3233

33-
t.doesNotThrow(() => {
34+
nodeAssert.doesNotThrow(() => {
3435
assert({type: 'foo', position: {start: {}}})
3536
}, 'should not throw if given an empty `position.start` object')
3637

37-
t.throws(
38+
nodeAssert.throws(
3839
() => {
3940
assert({type: 'foo', position: {end: 1}})
4041
},
4142
/`position.end` should be an object: `{ type: 'foo', position: { end: 1 } }`$/,
4243
'should throw if given a non-object `position.end`'
4344
)
4445

45-
t.doesNotThrow(() => {
46+
nodeAssert.doesNotThrow(() => {
4647
assert({type: 'foo', position: {end: null}})
4748
}, 'should not throw if given a null `position.end`')
4849

49-
t.doesNotThrow(() => {
50+
nodeAssert.doesNotThrow(() => {
5051
assert({type: 'foo', position: {end: {}}})
5152
}, 'should not throw if given an empty `position.end` object')
5253

53-
t.doesNotThrow(() => {
54+
nodeAssert.doesNotThrow(() => {
5455
assert({type: 'foo', position: {start: {line: null}}})
5556
}, 'should not throw if given a `position.start.line` to `null`')
5657

57-
t.doesNotThrow(() => {
58+
nodeAssert.doesNotThrow(() => {
5859
assert({type: 'foo', position: {start: {column: null}}})
5960
}, 'should not throw if given a `position.start.column` to `null`')
6061

61-
t.doesNotThrow(() => {
62+
nodeAssert.doesNotThrow(() => {
6263
assert({type: 'foo', position: {end: {line: null}}})
6364
}, 'should not throw if given a `position.end.line` to `null`')
6465

65-
t.doesNotThrow(() => {
66+
nodeAssert.doesNotThrow(() => {
6667
assert({type: 'foo', position: {end: {column: null}}})
6768
}, 'should not throw if given a `position.end.column` to `null`')
6869

69-
t.throws(
70+
nodeAssert.throws(
7071
() => {
7172
assert({type: 'foo', position: {start: {line: 0}}})
7273
},
7374
/`position.start.line` should be gte `1`: `{ type: 'foo', position: { start: { line: 0 } } }`$/,
7475
'should throw if `position.start.line` is less than 1'
7576
)
7677

77-
t.throws(
78+
nodeAssert.throws(
7879
() => {
7980
assert({type: 'foo', position: {start: {column: 0}}})
8081
},
8182
/`position.start.column` should be gte `1`: `{ type: 'foo', position: { start: { column: 0 } } }`$/,
8283
'should throw if `position.start.column` is less than 1'
8384
)
8485

85-
t.throws(
86+
nodeAssert.throws(
8687
() => {
8788
assert({type: 'foo', position: {end: {line: 0}}})
8889
},
8990
/`position.end.line` should be gte `1`: `{ type: 'foo', position: { end: { line: 0 } } }`$/,
9091
'should throw if `position.end.line` is less than 1'
9192
)
9293

93-
t.throws(
94+
nodeAssert.throws(
9495
() => {
9596
assert({type: 'foo', position: {end: {column: 0}}})
9697
},
9798
/`position.end.column` should be gte `1`: `{ type: 'foo', position: { end: { column: 0 } } }`$/,
9899
'should throw if `position.end.column` is less than 1'
99100
)
100-
101-
t.end()
102101
})

test/type.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('type', (t) => {
5-
t.throws(
5+
test('type', () => {
6+
nodeAssert.throws(
67
() => {
78
assert({})
89
},
910
/node should have a type: `{}`$/,
1011
'should throw if not given a `type` (#1)'
1112
)
1213

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

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

29-
t.throws(
30+
nodeAssert.throws(
3031
() => {
3132
assert({type: ''})
3233
},
3334
/`type` should not be empty: `{ type: '' }`$/,
3435
'should throw if given an empty string type'
3536
)
3637

37-
t.doesNotThrow(() => {
38+
nodeAssert.doesNotThrow(() => {
3839
assert({type: 'foo'})
3940
}, 'should not throw if given a non-empty type string')
40-
41-
t.end()
4241
})

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy