1
1
mirror of https://github.com/theoludwig/html-w3c-validator.git synced 2024-12-08 00:45:37 +01:00

refactor: usage of node:test instead of tap

This commit is contained in:
Théo LUDWIG 2023-07-02 12:18:21 +02:00
parent 3d24ffe971
commit 67806866ee
Signed by: theoludwig
GPG Key ID: ADFE5A563D718F3B
3 changed files with 14 additions and 19 deletions

9
.taprc
View File

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

View File

@ -1,21 +1,23 @@
import tap from 'tap'
import test from 'node:test'
import assert from 'node:assert/strict'
import { execa } from 'execa'
import { cli } from '../cli.js'
import { HTMLValidatorCommand } from '../HTMLValidatorCommand.js'
await tap.test('html-w3c-validator', async (t) => {
await t.test('should be instance of the command', async (t) => {
await test('html-w3c-validator', async (t) => {
await t.test('should be instance of the command', async () => {
const command = cli.process([])
t.equal(command instanceof HTMLValidatorCommand, true)
assert(command instanceof HTMLValidatorCommand)
})
await t.test('succeeds and validate the html correctly', async (t) => {
await t.test('succeeds and validate the html correctly', async () => {
const exampleURL = new URL('../../example', import.meta.url)
process.chdir(exampleURL.pathname)
await execa('rimraf', ['node_modules'])
await execa('npm', ['install'])
const { exitCode } = await execa('npm', ['run', 'test:html-w3c-validator'])
t.equal(exitCode, 0)
assert.strictEqual(exitCode, 0)
})
})

View File

@ -1,9 +1,11 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import fsMock from 'mock-fs'
import tap from 'tap'
import { isExistingPath } from '../isExistingPath.js'
await tap.test('utils/isExistingPath', async (t) => {
await test('utils/isExistingPath', async (t) => {
t.afterEach(() => {
fsMock.restore()
})
@ -12,13 +14,13 @@ await tap.test('utils/isExistingPath', async (t) => {
fsMock({
'/file.txt': ''
})
t.equal(await isExistingPath('/file.txt'), true)
assert.strictEqual(await isExistingPath('/file.txt'), true)
})
await t.test("should return false if the file doesn't exists", async () => {
fsMock({
'/file.txt': ''
})
t.equal(await isExistingPath('/randomfile.txt'), false)
assert.strictEqual(await isExistingPath('/randomfile.txt'), false)
})
})