-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: migrate from tap to node:test and c8 (#189)
- Loading branch information
1 parent
85fd6f0
commit 45f4669
Showing
9 changed files
with
183 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,32 @@ | ||
'use strict' | ||
|
||
const tap = require('tap') | ||
const test = tap.test | ||
const { test } = require('node:test') | ||
const fastify = require('fastify')() | ||
const plugin = require('../') | ||
|
||
fastify.register(plugin, { addHook: false, keys: new Set(['123456']) }) | ||
|
||
test('verifyBearerAuth', (t) => { | ||
test('verifyBearerAuth', async (t) => { | ||
t.plan(1) | ||
fastify.ready(() => { | ||
t.ok(fastify.verifyBearerAuth) | ||
}) | ||
await fastify.ready() | ||
t.assert.ok(fastify.verifyBearerAuth) | ||
}) | ||
|
||
test('verifyBearerAuthFactory', (t) => { | ||
test('verifyBearerAuthFactory', async (t) => { | ||
t.plan(1) | ||
fastify.ready(() => { | ||
t.ok(fastify.verifyBearerAuthFactory) | ||
}) | ||
await fastify.ready() | ||
t.assert.ok(fastify.verifyBearerAuthFactory) | ||
}) | ||
|
||
test('verifyBearerAuthFactory', (t) => { | ||
t.plan(1) | ||
fastify.ready(() => { | ||
const keys = { keys: new Set([123456]) } | ||
t.throws(() => fastify.verifyBearerAuthFactory(keys), /keys has to contain only string entries/) | ||
}) | ||
test('verifyBearerAuthFactory', async (t) => { | ||
t.plan(2) | ||
await fastify.ready() | ||
const keys = { keys: new Set([123456]) } | ||
await t.assert.rejects( | ||
async () => fastify.verifyBearerAuthFactory(keys), | ||
(err) => { | ||
t.assert.strictEqual(err.message, 'options.keys has to contain only string entries') | ||
return true | ||
} | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
'use strict' | ||
|
||
const tap = require('tap') | ||
const test = tap.test | ||
const { test } = require('node:test') | ||
const Fastify = require('fastify') | ||
const plugin = require('../') | ||
const { FST_BEARER_AUTH_INVALID_SPEC } = require('../lib/errors') | ||
|
||
test('throws FST_BEARER_AUTH_INVALID_SPEC when invalid value for specCompliance was used', async (t) => { | ||
t.plan(1) | ||
t.plan(2) | ||
|
||
const fastify = Fastify() | ||
|
||
t.rejects(async () => fastify.register(plugin, { keys: new Set(['123456']), specCompliance: 'invalid' }), new FST_BEARER_AUTH_INVALID_SPEC()) | ||
await t.assert.rejects( | ||
async () => fastify.register(plugin, { keys: new Set(['123456']), specCompliance: 'invalid' }), | ||
(err) => { | ||
t.assert.strictEqual(err.name, 'FastifyError') | ||
return true | ||
} | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.