refactor: usage of node:test instead of tap

This commit is contained in:
Théo LUDWIG 2023-06-24 09:58:45 +02:00
parent cbc6042bd5
commit 2d63a30f48
Signed by: theoludwig
GPG Key ID: ADFE5A563D718F3B
2 changed files with 10 additions and 16 deletions

8
.taprc
View File

@ -1,8 +0,0 @@
ts: false
jsx: false
flow: false
check-coverage: false
coverage: false
files:
- 'test/**/*.test.js'

View File

@ -1,9 +1,11 @@
const tap = require('tap') const test = require('node:test')
const assert = require('node:assert/strict')
const { markdownlint } = require('markdownlint').promises const { markdownlint } = require('markdownlint').promises
const relativeLinks = require('../src/index.js') const relativeLinks = require('../src/index.js')
tap.test('ensure we validate correctly', async (t) => { test('ensure we validate correctly', async () => {
const lintResults = await markdownlint({ const lintResults = await markdownlint({
files: ['test/fixtures/Valid.md', 'test/fixtures/Invalid.md'], files: ['test/fixtures/Valid.md', 'test/fixtures/Invalid.md'],
config: { config: {
@ -11,23 +13,23 @@ tap.test('ensure we validate correctly', async (t) => {
}, },
customRules: [relativeLinks] customRules: [relativeLinks]
}) })
t.equal(lintResults['test/fixtures/Valid.md'].length, 0) assert.equal(lintResults['test/fixtures/Valid.md'].length, 0)
t.equal(lintResults['test/fixtures/Invalid.md'].length, 2) assert.equal(lintResults['test/fixtures/Invalid.md'].length, 2)
t.equal( assert.equal(
lintResults['test/fixtures/Invalid.md'][0]?.ruleDescription, lintResults['test/fixtures/Invalid.md'][0]?.ruleDescription,
'Relative links should be valid' 'Relative links should be valid'
) )
t.equal( assert.equal(
lintResults['test/fixtures/Invalid.md'][0]?.errorDetail, lintResults['test/fixtures/Invalid.md'][0]?.errorDetail,
'Link "./basic.test.js" is dead' 'Link "./basic.test.js" is dead'
) )
t.equal( assert.equal(
lintResults['test/fixtures/Invalid.md'][1]?.ruleDescription, lintResults['test/fixtures/Invalid.md'][1]?.ruleDescription,
'Relative links should be valid' 'Relative links should be valid'
) )
t.equal( assert.equal(
lintResults['test/fixtures/Invalid.md'][1]?.errorDetail, lintResults['test/fixtures/Invalid.md'][1]?.errorDetail,
'Link "../image.png" is dead' 'Link "../image.png" is dead'
) )