Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: migrate from tap to node:test #151

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .taprc

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"types": "types/index.d.ts",
"scripts": {
"test": "npm run test:unit && npm run test:typescript",
"test:unit": "tap",
"test:unit": "c8 --100 node --test",
"test:typescript": "tsd",
"lint": "standard"
},
Expand All @@ -24,10 +24,10 @@
"devDependencies": {
"@fastify/pre-commit": "^2.1.0",
"@types/node": "^20.1.0",
"c8": "^10.1.2",
"fastify": "^5.0.0-alpha.4",
"fp-ts": "^2.11.2",
"standard": "^17.0.0",
"tap": "^21.0.0",
"tsd": "^0.31.1"
},
"homepage": "https://github.com/fastify/fastify-funky",
Expand Down
36 changes: 18 additions & 18 deletions test/funkyPlugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const fastify = require('fastify')
const { either, task, taskEither } = require('fp-ts')
const { test } = require('tap')
const { test } = require('node:test')
const {
initAppGet,
assertResponseTypeAndBody,
Expand All @@ -27,7 +27,7 @@ test('Promise: Correctly handles top-level promise', async (t) => {

const app = await initAppGet(t, route).ready()

t.teardown(() => {
t.after(() => {
app.close()
})

Expand All @@ -43,7 +43,7 @@ test('either: correctly parses right part of Either (sync)', async (t) => {

const app = await initAppGet(t, route).ready()

t.teardown(() => {
t.after(() => {
app.close()
})

Expand All @@ -60,7 +60,7 @@ test('either: correctly parses right part of Either (async)', async (t) => {

const app = await initAppGet(t, route).ready()

t.teardown(() => {
t.after(() => {
app.close()
})

Expand All @@ -77,7 +77,7 @@ test('either: correctly parses left part of Either when resolved (async)', async

const app = await initAppGet(t, route).ready()

t.teardown(() => {
t.after(() => {
app.close()
})

Expand All @@ -93,7 +93,7 @@ test('either: correctly parses left part of Either when resolved (sync)', async

const app = await initAppGet(t, route).ready()

t.teardown(() => {
t.after(() => {
app.close()
})

Expand All @@ -113,7 +113,7 @@ test('either: supports reply callback with the right part of Either', async (t)

const app = await initAppGet(t, route).ready()

t.teardown(() => {
t.after(() => {
app.close()
})

Expand All @@ -129,7 +129,7 @@ test('task: correctly parses Task result (sync)', async (t) => {

const app = await initAppGet(t, route).ready()

t.teardown(() => {
t.after(() => {
app.close()
})

Expand All @@ -145,7 +145,7 @@ test('task: correctly parses Task result (promise)', async (t) => {

const app = await initAppGet(t, route).ready()

t.teardown(() => {
t.after(() => {
app.close()
})

Expand All @@ -165,7 +165,7 @@ test('task: correctly handles Task throwing', async (t) => {

const app = await initAppGet(t, route).ready()

t.teardown(() => {
t.after(() => {
app.close()
})

Expand All @@ -185,7 +185,7 @@ test('task: correctly parses result of a plain parameterless function', async (t

const app = await initAppGet(t, route).ready()

t.teardown(() => {
t.after(() => {
app.close()
})

Expand All @@ -205,7 +205,7 @@ test('task: correctly parses result of a plain parameterless function that retur

const app = await initAppGet(t, route).ready()

t.teardown(() => {
t.after(() => {
app.close()
})

Expand All @@ -225,7 +225,7 @@ test('task: ignores parameterless function with parameters', async (t) => {

const app = await initAppGet(t, route).ready()

t.teardown(() => {
t.after(() => {
app.close()
})

Expand All @@ -241,7 +241,7 @@ test('task: handles empty body correctly', async (t) => {

const app = await initAppGet(t, route).ready()

t.teardown(() => {
t.after(() => {
app.close()
})

Expand All @@ -256,7 +256,7 @@ test('text content: correctly handles text response', async (t) => {

const app = fastify().register(fastifyFunky)

t.teardown(() => {
t.after(() => {
app.close()
})

Expand Down Expand Up @@ -290,7 +290,7 @@ test('taskEither: correctly parses TaskEither result (Either right)', async (t)

const app = await initAppGet(t, route).ready()

t.teardown(() => {
t.after(() => {
app.close()
})

Expand All @@ -306,7 +306,7 @@ test('taskEither: correctly parses TaskEither result (Task)', async (t) => {

const app = await initAppGet(t, route).ready()

t.teardown(() => {
t.after(() => {
app.close()
})

Expand All @@ -322,7 +322,7 @@ test('taskEither: correctly parses TaskEither result (Either left)', async (t) =

const app = await initAppGet(t, route).ready()

t.teardown(() => {
t.after(() => {
app.close()
})

Expand Down
18 changes: 9 additions & 9 deletions test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function initAppGet (t, endpoint) {

app.setErrorHandler((error, request, reply) => {
app.log.error(error)
t.strictSame(error.message, 'Invalid state')
t.assert.deepStrictEqual(error.message, 'Invalid state')
reply.status(500).send({ ok: false })
})

Expand All @@ -20,8 +20,8 @@ function initAppGet (t, endpoint) {

async function assertResponseTypeAndBody (t, app, endpoint, expectedType, expectedBody) {
const response = await app.inject().get(endpoint).end()
t.strictSame(response.headers['content-type'], expectedType)
t.strictSame(response.body, expectedBody)
t.assert.deepStrictEqual(response.headers['content-type'], expectedType)
t.assert.deepStrictEqual(response.body, expectedBody)
}

function assertCorrectResponse (t, app) {
Expand All @@ -30,8 +30,8 @@ function assertCorrectResponse (t, app) {
.get('/')
.end()
.then((response) => {
t.strictSame(response.statusCode, 200)
t.strictSame(response.json().user, { id: 1 })
t.assert.deepStrictEqual(response.statusCode, 200)
t.assert.deepStrictEqual(response.json().user, { id: 1 })
})
}

Expand All @@ -41,8 +41,8 @@ function assertCorrectResponseBody (t, app, expectedBody, expectedCode = 200) {
.get('/')
.end()
.then((response) => {
t.strictSame(response.statusCode, expectedCode)
t.strictSame(response.body, expectedBody)
t.assert.deepStrictEqual(response.statusCode, expectedCode)
t.assert.deepStrictEqual(response.body, expectedBody)
})
}

Expand All @@ -52,8 +52,8 @@ function assertErrorResponse (t, app) {
.get('/')
.end()
.then((response) => {
t.strictSame(response.statusCode, 500)
t.strictSame(response.json(), {
t.assert.deepStrictEqual(response.statusCode, 500)
t.assert.deepStrictEqual(response.json(), {
ok: false
})
})
Expand Down