Skip to content

Commit

Permalink
chore: migrate from tap to node:test and c8
Browse files Browse the repository at this point in the history
  • Loading branch information
dancastillo committed Oct 12, 2024
1 parent 31ae5c3 commit d210b26
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
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 @@ -8,7 +8,7 @@
"scripts": {
"lint": "standard index.js test/* benchmarks/*",
"test": "npm run test:unit && npm run test:typescript",
"test:unit": "tap",
"test:unit": "c8 --100 node --test",
"test:typescript": "tsd"
},
"standard": {
Expand All @@ -35,8 +35,8 @@
"devDependencies": {
"@fastify/pre-commit": "^2.1.0",
"benchmark": "2.1.4",
"c8": "^10.1.2",
"standard": "17.1.2",
"tap": "^18.7.2",
"tsd": "^0.31.0"
},
"repository": {
Expand Down
14 changes: 7 additions & 7 deletions test/Negotiator.test.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
'use strict'

const test = require('tap').test
const { test } = require('node:test')
const testCases = require('./testCases')
const Negotiator = require('../index').Negotiator

test('should create Negotiator-Instances', t => {
t.plan(2)
t.ok(new Negotiator() instanceof Negotiator)
t.ok(Negotiator() instanceof Negotiator)
t.assert.ok(new Negotiator() instanceof Negotiator)
t.assert.ok(Negotiator() instanceof Negotiator)
})

for (const [header, supportedEncodings, expected] of testCases) {
test(`should return ${expected} when ${header} and ${supportedEncodings}`, t => {
t.plan(4)
const negotiatorNoCache = new Negotiator({ supportedValues: supportedEncodings })
t.equal(negotiatorNoCache.negotiate(header), expected, `should return ${expected} when ${header} and ${supportedEncodings}`)
t.assert.strictEqual(negotiatorNoCache.negotiate(header), expected, `should return ${expected} when ${header} and ${supportedEncodings}`)

const negotiatorNonClass = Negotiator({ supportedValues: supportedEncodings })
t.equal(negotiatorNonClass.negotiate(header), expected, `should return ${expected} when ${header} and ${supportedEncodings}`)
t.assert.strictEqual(negotiatorNonClass.negotiate(header), expected, `should return ${expected} when ${header} and ${supportedEncodings}`)

const negotiatorCache = new Negotiator({ supportedValues: supportedEncodings, cache: new Map() })
t.equal(negotiatorCache.negotiate(header), expected, `should return ${expected} when ${header} and ${supportedEncodings}`)
t.equal(negotiatorCache.negotiate(header), expected, `should return ${expected} when ${header} and ${supportedEncodings}`)
t.assert.strictEqual(negotiatorCache.negotiate(header), expected, `should return ${expected} when ${header} and ${supportedEncodings}`)
t.assert.strictEqual(negotiatorCache.negotiate(header), expected, `should return ${expected} when ${header} and ${supportedEncodings}`)
})
}
4 changes: 2 additions & 2 deletions test/negotiate.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict'

const test = require('tap').test
const { test } = require('node:test')
const testCases = require('./testCases')
const negotiate = require('../index').negotiate

for (const [header, supportedEncodings, expected] of testCases) {
test(`should return ${expected} when ${header} and ${supportedEncodings}`, t => {
t.plan(1)
t.equal(negotiate(header, supportedEncodings), expected)
t.assert.strictEqual(negotiate(header, supportedEncodings), expected)
})
}

0 comments on commit d210b26

Please sign in to comment.