Skip to content

Commit

Permalink
chore: Improved tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
ShogunPanda committed Feb 6, 2024
1 parent 0fab6f7 commit 0fa3c25
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"format": "prettier -w src test",
"lint": "eslint --cache --ext .js,.jsx,.ts,.tsx src test",
"typecheck": "tsc -p . --emitDeclarationOnly",
"test": "c8 -c test/config/c8-local.json node --import tsx test/index.test.ts",
"test:ci": "c8 -c test/config/c8-ci.json node --import tsx --test-reporter=tap test/index.test.ts",
"test": "c8 -c test/config/c8-local.json node --import tsx --test test/*.test.ts",
"test:ci": "c8 -c test/config/c8-ci.json node --import tsx --test-reporter=tap --test test/*.test.ts",
"ci": "npm run build && npm run test:ci",
"prepublishOnly": "npm run ci",
"postpublish": "git push origin && git push origin -f --tags"
Expand Down
7 changes: 0 additions & 7 deletions test/config/tap.yml

This file was deleted.

16 changes: 8 additions & 8 deletions test/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-floating-promises */

import fastify, { type RouteOptions } from 'fastify'
import { strictEqual } from 'node:assert'
import { deepStrictEqual } from 'node:assert'
import { test, type MockedObject, type TestContext } from 'node:test'
import { table } from 'table'
import { plugin as fastifyPrintRoutes } from '../src/index.js'
Expand Down Expand Up @@ -68,7 +68,7 @@ test('should correctly list unhidden routes with colors', async t => {
await server.listen({ port: 0 })
await server.close()

strictEqual(
deepStrictEqual(
// eslint-disable-next-line no-control-regex
logCalls.mock.calls[0].arguments[0].replaceAll(/\u001B\[\d+m/g, ''),
generateOutput([
Expand Down Expand Up @@ -176,7 +176,7 @@ test('should correctly include querystring in the URL if present', async t => {
await server.listen({ port: 0 })
await server.close()

strictEqual(
deepStrictEqual(
// eslint-disable-next-line no-control-regex
logCalls.mock.calls[0].arguments[0].replaceAll(/\u001B\[\d+m/g, ''),
generateOutput(
Expand Down Expand Up @@ -221,7 +221,7 @@ test('should correctly list unhidden routes without colors', async t => {
await server.listen({ port: 0 })
await server.close()

strictEqual(
deepStrictEqual(
logCalls.mock.calls[0].arguments[0],
generateOutput([
['GET', '/abc', ''],
Expand Down Expand Up @@ -273,7 +273,7 @@ test('should correctly list filtered routes without colors', async t => {
await server.listen({ port: 0 })
await server.close()

strictEqual(
deepStrictEqual(
logCalls.mock.calls[0].arguments[0],
generateOutput([
['GET', '/abc', 'Title'],
Expand Down Expand Up @@ -327,7 +327,7 @@ test('should correctly compact routes', async t => {
await server.listen({ port: 0 })
await server.close()

strictEqual(
deepStrictEqual(
// eslint-disable-next-line no-control-regex
logCalls.mock.calls[0].arguments[0].replaceAll(/\u001B\[\d+m/g, ''),
generateOutput([
Expand Down Expand Up @@ -366,7 +366,7 @@ test('should omit description column if not needed', async t => {
await server.listen({ port: 0 })
await server.close()

strictEqual(
deepStrictEqual(
logCalls.mock.calls[0].arguments[0],
generateOutput(
[
Expand All @@ -389,5 +389,5 @@ test('should print nothing when no routes are available', async t => {
await server.listen({ port: 0 })
await server.close()

strictEqual(logCalls.mock.callCount(), 0)
deepStrictEqual(logCalls.mock.callCount(), 0)
})

0 comments on commit 0fa3c25

Please sign in to comment.