-
-
Notifications
You must be signed in to change notification settings - Fork 45
fix: migrate from tap to node test and c8 #248
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,38 +1,35 @@ | ||
| 'use strict' | ||
|
|
||
| const { test } = require('tap') | ||
| const { test } = require('node:test') | ||
| const fp = require('../plugin') | ||
|
|
||
| test('webpack removes require.main.filename', (t) => { | ||
| test('webpack removes require.main.filename', async (t) => { | ||
|
||
| const filename = require.main.filename | ||
| const info = console.info | ||
| t.teardown(() => { | ||
| t.after(() => { | ||
| require.main.filename = filename | ||
| console.info = info | ||
| }) | ||
|
|
||
| require.main.filename = null | ||
|
|
||
| console.info = function (msg) { | ||
| t.fail('logged: ' + msg) | ||
| t.assert.fail('logged: ' + msg) | ||
| } | ||
|
|
||
| fp((fastify, opts, next) => { | ||
| next() | ||
| }, { | ||
| fastify: '^5.0.0' | ||
| }) | ||
|
|
||
| t.end() | ||
| }) | ||
|
|
||
| test('support faux modules', (t) => { | ||
| test('support faux modules', async (t) => { | ||
| const plugin = fp((fastify, opts, next) => { | ||
| next() | ||
| }) | ||
|
|
||
| t.equal(plugin.default, plugin) | ||
| t.end() | ||
| t.assert.strictEqual(plugin.default, plugin) | ||
| }) | ||
|
|
||
| test('support faux modules does not override existing default field in babel module', (t) => { | ||
|
|
@@ -44,66 +41,60 @@ test('support faux modules does not override existing default field in babel mod | |
|
|
||
| const plugin = fp(module) | ||
|
|
||
| t.equal(plugin.default, 'Existing default field') | ||
| t.end() | ||
| t.assert.strictEqual(plugin.default, 'Existing default field') | ||
| }) | ||
|
|
||
| test('support ts named imports', (t) => { | ||
| test('support ts named imports', async (t) => { | ||
| const plugin = fp((fastify, opts, next) => { | ||
| next() | ||
| }, { | ||
| name: 'hello' | ||
| }) | ||
|
|
||
| t.equal(plugin.hello, plugin) | ||
| t.end() | ||
| t.assert.strictEqual(plugin.hello, plugin) | ||
| }) | ||
|
|
||
| test('from kebab-case to camelCase', (t) => { | ||
| test('from kebab-case to camelCase', async (t) => { | ||
| const plugin = fp((fastify, opts, next) => { | ||
| next() | ||
| }, { | ||
| name: 'hello-world' | ||
| }) | ||
|
|
||
| t.equal(plugin.helloWorld, plugin) | ||
| t.end() | ||
| t.assert.strictEqual(plugin.helloWorld, plugin) | ||
| }) | ||
|
|
||
| test('from @-prefixed named imports', (t) => { | ||
| test('from @-prefixed named imports', async (t) => { | ||
| const plugin = fp((fastify, opts, next) => { | ||
| next() | ||
| }, { | ||
| name: '@hello/world' | ||
| }) | ||
|
|
||
| t.equal(plugin.helloWorld, plugin) | ||
| t.end() | ||
| t.assert.strictEqual(plugin.helloWorld, plugin) | ||
| }) | ||
|
|
||
| test('from @-prefixed named kebab-case to camelCase', (t) => { | ||
| test('from @-prefixed named kebab-case to camelCase', async (t) => { | ||
| const plugin = fp((fastify, opts, next) => { | ||
| next() | ||
| }, { | ||
| name: '@hello/my-world' | ||
| }) | ||
|
|
||
| t.equal(plugin.helloMyWorld, plugin) | ||
| t.end() | ||
| t.assert.strictEqual(plugin.helloMyWorld, plugin) | ||
| }) | ||
|
|
||
| test('from kebab-case to camelCase multiple words', (t) => { | ||
| test('from kebab-case to camelCase multiple words', async (t) => { | ||
| const plugin = fp((fastify, opts, next) => { | ||
| next() | ||
| }, { | ||
| name: 'hello-long-world' | ||
| }) | ||
|
|
||
| t.equal(plugin.helloLongWorld, plugin) | ||
| t.end() | ||
| t.assert.strictEqual(plugin.helloLongWorld, plugin) | ||
| }) | ||
|
|
||
| test('from kebab-case to camelCase multiple words does not override', (t) => { | ||
| test('from kebab-case to camelCase multiple words does not override', async (t) => { | ||
| const fn = (fastify, opts, next) => { | ||
| next() | ||
| } | ||
|
|
@@ -115,6 +106,5 @@ test('from kebab-case to camelCase multiple words does not override', (t) => { | |
| name: 'hello-long-world' | ||
| }) | ||
|
|
||
| t.equal(plugin.helloLongWorld, foobar) | ||
| t.end() | ||
| t.assert.strictEqual(plugin.helloLongWorld, foobar) | ||
| }) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,14 @@ | ||
| 'use strict' | ||
|
|
||
| const t = require('tap') | ||
| const test = t.test | ||
| const { test } = require('node:test') | ||
| const fp = require('../plugin') | ||
|
|
||
| test('anonymous function should be named composite.test0', t => { | ||
| test('anonymous function should be named composite.test0', async (t) => { | ||
| t.plan(2) | ||
|
|
||
| const fn = fp((fastify, opts, next) => { | ||
| next() | ||
| }) | ||
|
|
||
| t.equal(fn[Symbol.for('plugin-meta')].name, 'composite.test-auto-0') | ||
| t.equal(fn[Symbol.for('fastify.display-name')], 'composite.test-auto-0') | ||
| t.assert.strictEqual(fn[Symbol.for('plugin-meta')].name, 'composite.test-auto-0') | ||
| t.assert.strictEqual(fn[Symbol.for('fastify.display-name')], 'composite.test-auto-0') | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,15 @@ | ||
| 'use strict' | ||
|
|
||
| const t = require('tap') | ||
| const test = t.test | ||
| const { test } = require('node:test') | ||
| const fp = require('../plugin') | ||
|
|
||
| test('anonymous function should be named mu1tip1e.composite.test', t => { | ||
| test('anonymous function should be named mu1tip1e.composite.test', async (t) => { | ||
| t.plan(2) | ||
|
|
||
| const fn = fp((fastify, opts, next) => { | ||
| next() | ||
| }) | ||
|
|
||
| t.equal(fn[Symbol.for('plugin-meta')].name, 'mu1tip1e.composite.test-auto-0') | ||
| t.equal(fn[Symbol.for('fastify.display-name')], 'mu1tip1e.composite.test-auto-0') | ||
| t.assert.strictEqual(fn[Symbol.for('plugin-meta')].name, 'mu1tip1e.composite.test-auto-0') | ||
| t.assert.strictEqual(fn[Symbol.for('fastify.display-name')], 'mu1tip1e.composite.test-auto-0') | ||
| }) |
Uh oh!
There was an error while loading. Please reload this page.