Skip to content

Commit

Permalink
Use Node test runner
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jan 25, 2023
1 parent eede172 commit ab7eb0b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ jobs:
strategy:
matrix:
node:
- lts/fermium
- lts/gallium
- node
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@types/mdast": "^3.0.0"
},
"devDependencies": {
"@types/tape": "^4.0.0",
"@types/node": "^18.0.0",
"c8": "^7.0.0",
"prettier": "^2.0.0",
"remark-cli": "^11.0.0",
Expand Down
31 changes: 17 additions & 14 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import test from 'tape'
import assert from 'node:assert/strict'
import test from 'node:test'
import {toString} from './index.js'

test('toString', (t) => {
test('toString', () => {
// @ts-expect-error: runtime.
t.equal(toString(), '', 'should not fail on a missing node')
t.equal(toString(null), '', 'should not fail on `null` missing node')
assert.equal(toString(), '', 'should not fail on a missing node')
assert.equal(toString(null), '', 'should not fail on `null` missing node')

t.equal(toString({value: 'foo'}), 'foo', 'should not fail on nodes w/o type')
assert.equal(
toString({value: 'foo'}),
'foo',
'should not fail on nodes w/o type'
)

t.equal(
assert.equal(
toString({
value: 'foo',
alt: 'bar',
Expand All @@ -19,37 +24,35 @@ test('toString', (t) => {
'should prefer `value` over all others'
)

t.equal(
assert.equal(
toString({alt: 'bar', title: 'baz', children: [{value: 'qux'}]}),
'bar',
'should prefer `alt` over all others'
)

t.equal(
assert.equal(
toString({title: 'baz', children: [{value: 'qux'}]}),
'qux',
'should *not* prefer `title` over all others'
)

t.equal(
assert.equal(
toString({alt: 'bar'}, {includeImageAlt: false}),
'',
'should *not* include `alt` w/ `includeImageAlt: false`'
)

t.equal(
assert.equal(
toString({children: [{value: 'foo'}, {alt: 'bar'}, {title: 'baz'}]}),
'foobar',
'should serialize children'
)

t.equal(
assert.equal(
toString([{value: 'foo'}, {alt: 'bar'}, {title: 'baz'}]),
'foobar',
'should serialize a list of nodes'
)

t.equal(toString({}), '', 'should produce an empty string otherwise')

t.end()
assert.equal(toString({}), '', 'should produce an empty string otherwise')
})

0 comments on commit ab7eb0b

Please sign in to comment.