Skip to content

Commit b2a17e5

Browse files
committed
test: migrate from tap to node fix-313.test.js
1 parent 37cca64 commit b2a17e5

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

test/fix-313.test.js

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
const test = require('tap').test
3+
const test = require('node:test')
44
const FormData = require('form-data')
55
const Fastify = require('fastify')
66
const multipart = require('..')
@@ -17,38 +17,38 @@ test('should store file on disk, remove on response when attach fields to body i
1717
t.plan(25)
1818

1919
const fastify = Fastify()
20-
t.teardown(fastify.close.bind(fastify))
20+
t.after(() => fastify.close())
2121

2222
fastify.register(multipart, {
2323
attachFieldsToBody: true
2424
})
2525

2626
fastify.post('/', async function (req, reply) {
27-
t.ok(req.isMultipart())
27+
t.assert.ok(req.isMultipart())
2828

2929
const files = await req.saveRequestFiles()
3030

31-
t.ok(files[0].filepath)
32-
t.equal(files[0].type, 'file')
33-
t.equal(files[0].fieldname, 'upload')
34-
t.equal(files[0].filename, 'README.md')
35-
t.equal(files[0].encoding, '7bit')
36-
t.equal(files[0].mimetype, 'text/markdown')
37-
t.ok(files[0].fields.upload)
38-
t.ok(files[1].filepath)
39-
t.equal(files[1].type, 'file')
40-
t.equal(files[1].fieldname, 'upload')
41-
t.equal(files[1].filename, 'README.md')
42-
t.equal(files[1].encoding, '7bit')
43-
t.equal(files[1].mimetype, 'text/markdown')
44-
t.ok(files[1].fields.upload)
45-
t.ok(files[2].filepath)
46-
t.equal(files[2].type, 'file')
47-
t.equal(files[2].fieldname, 'other')
48-
t.equal(files[2].filename, 'README.md')
49-
t.equal(files[2].encoding, '7bit')
50-
t.equal(files[2].mimetype, 'text/markdown')
51-
t.ok(files[2].fields.upload)
31+
t.assert.ok(files[0].filepath)
32+
t.assert.strictEqual(files[0].type, 'file')
33+
t.assert.strictEqual(files[0].fieldname, 'upload')
34+
t.assert.strictEqual(files[0].filename, 'README.md')
35+
t.assert.strictEqual(files[0].encoding, '7bit')
36+
t.assert.strictEqual(files[0].mimetype, 'text/markdown')
37+
t.assert.ok(files[0].fields.upload)
38+
t.assert.ok(files[1].filepath)
39+
t.assert.strictEqual(files[1].type, 'file')
40+
t.assert.strictEqual(files[1].fieldname, 'upload')
41+
t.assert.strictEqual(files[1].filename, 'README.md')
42+
t.assert.strictEqual(files[1].encoding, '7bit')
43+
t.assert.strictEqual(files[1].mimetype, 'text/markdown')
44+
t.assert.ok(files[1].fields.upload)
45+
t.assert.ok(files[2].filepath)
46+
t.assert.strictEqual(files[2].type, 'file')
47+
t.assert.strictEqual(files[2].fieldname, 'other')
48+
t.assert.strictEqual(files[2].filename, 'README.md')
49+
t.assert.strictEqual(files[2].encoding, '7bit')
50+
t.assert.strictEqual(files[2].mimetype, 'text/markdown')
51+
t.assert.ok(files[2].fields.upload)
5252

5353
await access(files[0].filepath, fs.constants.F_OK)
5454
await access(files[1].filepath, fs.constants.F_OK)
@@ -63,8 +63,8 @@ test('should store file on disk, remove on response when attach fields to body i
6363
try {
6464
await access(request.tmpUploads[0], fs.constants.F_OK)
6565
} catch (error) {
66-
t.equal(error.code, 'ENOENT')
67-
t.pass('Temp file was removed after response')
66+
t.assert.strictEqual(error.code, 'ENOENT')
67+
t.assert.ok('Temp file was removed after response')
6868
ee.emit('response')
6969
}
7070
})
@@ -89,7 +89,7 @@ test('should store file on disk, remove on response when attach fields to body i
8989
form.pipe(req)
9090

9191
const [res] = await once(req, 'response')
92-
t.equal(res.statusCode, 200)
92+
t.assert.strictEqual(res.statusCode, 200)
9393
res.resume()
9494
await once(res, 'end')
9595
await once(ee, 'response')
@@ -99,7 +99,7 @@ test('should throw on saving request files when attach fields to body is true bu
9999
t.plan(3)
100100

101101
const fastify = Fastify()
102-
t.teardown(fastify.close.bind(fastify))
102+
t.after(() => fastify.close())
103103

104104
fastify.register(multipart, {
105105
attachFieldsToBody: true,
@@ -111,13 +111,13 @@ test('should throw on saving request files when attach fields to body is true bu
111111
})
112112

113113
fastify.post('/', async function (req, reply) {
114-
t.ok(req.isMultipart())
114+
t.assert.ok(req.isMultipart())
115115

116116
try {
117117
await req.saveRequestFiles()
118118
reply.code(200).send()
119119
} catch (error) {
120-
t.ok(error instanceof fastify.multipartErrors.FileBufferNotFoundError)
120+
t.assert.ok(error instanceof fastify.multipartErrors.FileBufferNotFoundError)
121121
reply.code(500).send()
122122
}
123123
})
@@ -140,7 +140,7 @@ test('should throw on saving request files when attach fields to body is true bu
140140
form.pipe(req)
141141

142142
const [res] = await once(req, 'response')
143-
t.equal(res.statusCode, 500)
143+
t.assert.strictEqual(res.statusCode, 500)
144144
res.resume()
145145
await once(res, 'end')
146146
})

0 commit comments

Comments
 (0)