Skip to content

Commit

Permalink
fix: migrate from tap to node test and c8
Browse files Browse the repository at this point in the history
  • Loading branch information
dancastillo committed Aug 8, 2024
1 parent 83d2be5 commit 40362f2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
2 changes: 0 additions & 2 deletions .taprc

This file was deleted.

5 changes: 2 additions & 3 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 node --test",
"test:typescript": "tsd",
"lint": "standard",
"lint:fix": "standard --fix"
Expand All @@ -28,12 +28,11 @@
},
"devDependencies": {
"@fastify/pre-commit": "^2.1.0",
"@sinonjs/fake-timers": "^11.2.2",
"@types/node": "^22.0.0",
"c8": "^10.1.2",
"fastify": "^5.0.0-alpha.2",
"prettier": "^3.2.5",
"standard": "^17.1.0",
"tap": "^20.0.0",
"toad-scheduler": "^3.0.1",
"tsd": "^0.31.1"
},
Expand Down
16 changes: 6 additions & 10 deletions test/schedulePlugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@

const fastify = require('fastify')
const fastifySchedulePlugin = require('../index')
const FakeTimers = require('@sinonjs/fake-timers')
const test = require('tap').test
const { test, mock } = require('node:test')
const { SimpleIntervalJob, Task } = require('toad-scheduler')

test('schedulePlugin correctly stops on application close', async (t) => {
const clock = FakeTimers.install()

t.teardown(() => {
clock.uninstall()
})
const clock = mock.timers
clock.enable(0)

const app = fastify({ logger: true })
app.register(fastifySchedulePlugin)
Expand All @@ -30,12 +26,12 @@ test('schedulePlugin correctly stops on application close', async (t) => {

app.scheduler.addSimpleIntervalJob(job)

t.equal(counter, 0)
t.assert.equal(counter, 0)
clock.tick(20)
t.equal(counter, 2)
t.assert.equal(counter, 2)

await app.close()
clock.tick(20)

t.equal(counter, 2)
t.assert.equal(counter, 2)
})

0 comments on commit 40362f2

Please sign in to comment.