-
Notifications
You must be signed in to change notification settings - Fork 19
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
chore: migrate from tap to node:test and c8 #168
Merged
gurgunday
merged 2 commits into
fastify:master
from
dancastillo:migrate-tests-to-node-test-c8
Oct 30, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,6 @@ module.exports = { | |
}, | ||
env: { | ||
node: true, | ||
mocha: true, | ||
es6: true | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,75 +1,78 @@ | ||
'use strict' | ||
|
||
const Busboy = require('../lib/main') | ||
const { test } = require('tap') | ||
const { test } = require('node:test') | ||
|
||
test('busboy-constructor - should throw an Error if no options are provided', t => { | ||
t.plan(1) | ||
|
||
t.throws(() => new Busboy(), new Error('Busboy expected an options-Object.')) | ||
t.assert.throws(() => new Busboy(), { message: 'Busboy expected an options-Object.' }) | ||
}) | ||
|
||
test('busboy-constructor - should throw an Error if options does not contain headers', t => { | ||
t.plan(1) | ||
|
||
t.throws(() => new Busboy({}), new Error('Busboy expected an options-Object with headers-attribute.')) | ||
t.assert.throws(() => new Busboy({}), { message: 'Busboy expected an options-Object with headers-attribute.' }) | ||
}) | ||
|
||
test('busboy-constructor - if busboy is called without new-operator, still creates a busboy instance', t => { | ||
t.plan(1) | ||
|
||
const busboyInstance = Busboy({ headers: { 'content-type': 'application/x-www-form-urlencoded' } }) | ||
t.type(busboyInstance, Busboy) | ||
t.assert.strictEqual(busboyInstance instanceof Busboy, true) | ||
}) | ||
|
||
test('busboy-constructor - should throw an Error if content-type is not set', t => { | ||
t.plan(1) | ||
|
||
t.throws(() => new Busboy({ headers: {} }), new Error('Missing Content-Type-header.')) | ||
t.assert.throws(() => new Busboy({ headers: {} }), { message: 'Missing Content-Type-header.' }) | ||
}) | ||
|
||
test('busboy-constructor - should throw an Error if content-type is unsupported', t => { | ||
t.plan(1) | ||
|
||
t.throws(() => new Busboy({ headers: { 'content-type': 'unsupported' } }), new Error('Unsupported Content-Type.')) | ||
t.assert.throws(() => new Busboy({ headers: { 'content-type': 'unsupported' } }), { message: 'Unsupported Content-Type.' }) | ||
}) | ||
|
||
test('busboy-constructor - should not throw an Error if content-type is urlencoded', t => { | ||
t.plan(1) | ||
|
||
t.doesNotThrow(() => new Busboy({ headers: { 'content-type': 'application/x-www-form-urlencoded' } })) | ||
t.assert.doesNotThrow(() => new Busboy({ headers: { 'content-type': 'application/x-www-form-urlencoded' } })) | ||
}) | ||
|
||
test('busboy-constructor - if busboy is called without stream options autoDestroy is set to false', t => { | ||
t.plan(1) | ||
|
||
const busboyInstance = Busboy({ headers: { 'content-type': 'application/x-www-form-urlencoded' } }) | ||
t.equal(busboyInstance._writableState.autoDestroy, false) | ||
t.assert.strictEqual(busboyInstance._writableState.autoDestroy, false) | ||
}) | ||
|
||
test('busboy-constructor - if busboy is called with invalid value for stream option highWaterMark we should throw', t => { | ||
t.plan(1) | ||
|
||
t.throws(() => Busboy({ highWaterMark: 'not_allowed_value_for_highWaterMark', headers: { 'content-type': 'application/x-www-form-urlencoded' } }), new Error('not_allowed_value_for_highWaterMark')) | ||
t.assert.throws(() => Busboy({ highWaterMark: 'not_allowed_value_for_highWaterMark', headers: { 'content-type': 'application/x-www-form-urlencoded' } }), { | ||
// nmae: 'Error', | ||
message: 'The property \'options.highWaterMark\' is invalid. Received \'not_allowed_value_for_highWaterMark\'' | ||
}) | ||
}) | ||
|
||
test('busboy-constructor - if busboy is called with stream options and autoDestroy:true, autoDestroy should be set to true', t => { | ||
t.plan(1) | ||
|
||
const busboyInstance = Busboy({ autoDestroy: true, headers: { 'content-type': 'application/x-www-form-urlencoded' } }) | ||
t.equal(busboyInstance._writableState.autoDestroy, true) | ||
t.assert.strictEqual(busboyInstance._writableState.autoDestroy, true) | ||
}) | ||
|
||
test('busboy-constructor - busboy should be initialized with private attribute _done set as false', t => { | ||
t.plan(1) | ||
|
||
const busboyInstance = Busboy({ headers: { 'content-type': 'application/x-www-form-urlencoded' } }) | ||
t.equal(busboyInstance._done, false) | ||
t.assert.strictEqual(busboyInstance._done, false) | ||
}) | ||
|
||
test('busboy-constructor - busboy should be initialized with private attribute _finished set as false', t => { | ||
t.plan(1) | ||
|
||
const busboyInstance = Busboy({ headers: { 'content-type': 'application/x-www-form-urlencoded' } }) | ||
t.equal(busboyInstance._finished, false) | ||
t.assert.strictEqual(busboyInstance._finished, false) | ||
}) |
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
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,22 +1,22 @@ | ||
'use strict' | ||
|
||
const { test } = require('tap') | ||
const { test } = require('node:test') | ||
const Dicer = require('../deps/dicer/lib/Dicer') | ||
|
||
test('dicer-constructor', t => { | ||
test('dicer-constructor', async t => { | ||
t.plan(2) | ||
|
||
t.test('should throw an Error when no options parameter is supplied to Dicer', t => { | ||
await t.test('should throw an Error when no options parameter is supplied to Dicer', t => { | ||
t.plan(1) | ||
|
||
t.throws(() => new Dicer(), new Error('Boundary required')) | ||
t.assert.throws(() => new Dicer(), { message: 'Boundary required' }) | ||
}) | ||
|
||
t.test('without new operator a new dicer instance will be initialized', t => { | ||
await t.test('without new operator a new dicer instance will be initialized', t => { | ||
t.plan(1) | ||
|
||
t.type(Dicer({ | ||
t.assert.strictEqual(Dicer({ | ||
boundary: '----boundary' | ||
}), Dicer) | ||
}) instanceof Dicer, true) | ||
}) | ||
}) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cannot do
c8 ---100
since there is not already 100% coverage being tracked here #126There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice! I didn't know we could separate them