Skip to content

Commit

Permalink
chore: migrate from tap to node:test and c8 (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
inyourtime authored Nov 26, 2024
1 parent 2a22e20 commit e783064
Show file tree
Hide file tree
Showing 7 changed files with 248 additions and 253 deletions.
3 changes: 0 additions & 3 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 @@ -13,7 +13,7 @@
"mysql:5.5": "docker run -d -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes --rm mysql:5.5",
"mysql:8.0": "docker run -d -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes --rm mysql:8.0",
"test": "npm run test:unit && npm run test:typescript",
"test:unit": "tap",
"test:unit": "c8 --100 node --test",
"test:typescript": "tsd"
},
"repository": {
Expand All @@ -38,9 +38,9 @@
},
"devDependencies": {
"@types/node": "^22.0.0",
"c8": "^10.1.2",
"fastify": "^5.0.0",
"standard": "^17.1.0",
"tap": "^19.2.5",
"tsd": "^0.31.1"
},
"publishConfig": {
Expand Down
30 changes: 12 additions & 18 deletions test/closing.test.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
'use strict'

const test = require('tap').test
const { test } = require('node:test')
const Fastify = require('fastify')
const fastifyMysql = require('../index')

test('callback connection', (t) => {
test('callback connection', (t, done) => {
let fastify = null

fastify = Fastify()
fastify.register(fastifyMysql, {
type: 'connection',
connectionString: 'mysql://root@localhost/mysql'
})
t.after(() => fastify.close())

fastify.ready((err) => {
t.error(err)
t.assert.ifError(err)

fastify.mysql.query('SELECT 1 AS `ping`', (err, results) => {
t.error(err)
t.ok(results[0].ping === 1)

fastify.close((closeErr) => {
t.error(closeErr)
t.end()
})
t.assert.ifError(err)
t.assert.ok(results[0].ping === 1)
done()
})
})
})

test('promise connection', (t) => {
test('promise connection', (t, done) => {
let fastify = null

fastify = Fastify()
Expand All @@ -37,17 +34,14 @@ test('promise connection', (t) => {
type: 'connection',
connectionString: 'mysql://root@localhost/mysql'
})
t.after(() => fastify.close())

fastify.ready((err) => {
t.error(err)
t.assert.ifError(err)

fastify.mysql.query('SELECT 1 AS `ping`').then(([results]) => {
t.ok(results[0].ping === 1)

fastify.close((closeErr) => {
t.error(closeErr)
t.end()
})
t.assert.ok(results[0].ping === 1)
done()
})
})
})
Loading

0 comments on commit e783064

Please sign in to comment.