Skip to content

Commit b448dd3

Browse files
committed
fix test and type error
1 parent c7c9262 commit b448dd3

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"@biomejs/biome": "2.2.2",
2525
"@tinyhttp/app": "^2.4.0",
2626
"@types/express": "^5.0.3",
27-
"@types/node": "^18.19.76",
27+
"@types/node": "^18",
2828
"c8": "10.1.2",
2929
"express": "^5.1.0",
3030
"supertest-fetch": "^2.0.0",

pnpm-lock.yaml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Buffer } from 'node:buffer'
1+
import { Buffer, File } from 'node:buffer'
22
import type { ServerResponse as Response } from 'node:http'
33
import type { LimitErrorFn, NextFunction, ParserOptions, ReqWithBody } from './types.js'
44
import { checkType, hasBody } from './utils.js'

test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import assert from 'node:assert/strict'
2-
import { Buffer } from 'node:buffer'
2+
import { Buffer, File } from 'node:buffer'
33
import { createServer } from 'node:http'
44
import { describe, it } from 'node:test'
55
import { App } from '@tinyhttp/app'
@@ -355,7 +355,7 @@ describe('Multipart', () => {
355355
it('should parse multipart with files', async () => {
356356
const fd = new FormData()
357357
const file = new File(['hello world'], 'hello.txt', { type: 'text/plain' })
358-
fd.set('file', file)
358+
fd.set('file', file as globalThis.File)
359359
const server = createServer(async (req: ReqWithBody<{ file: [File] }>, res) => {
360360
await multipart()(req, res, (err) => err && console.log(err))
361361

@@ -382,8 +382,8 @@ describe('Multipart', () => {
382382
new File(['bye world'], 'bye.txt', { type: 'text/plain' })
383383
]
384384

385-
fd.set('file1', files[0] as Blob)
386-
fd.set('file2', files[1] as Blob)
385+
fd.set('file1', files[0] as globalThis.File)
386+
fd.set('file2', files[1] as globalThis.File)
387387

388388
const server = createServer(async (req: ReqWithBody<{ file1: [File]; file2: [File] }>, res) => {
389389
await multipart()(req, res, (err) => err && console.log(err))
@@ -407,7 +407,7 @@ describe('Multipart', () => {
407407
it('should support binary files', async () => {
408408
const fd = new FormData()
409409
const file = new File([new Uint8Array([1, 2, 3])], 'blob.bin', { type: 'application/octet-stream' })
410-
fd.set('file', file as Blob)
410+
fd.set('file', file as globalThis.File)
411411

412412
const server = createServer(async (req: ReqWithBody<{ file: [File] }>, res) => {
413413
await multipart()(req, res, (err) => err && console.log(err))
@@ -497,8 +497,8 @@ describe('Limits', () => {
497497

498498
const fd = new FormData()
499499

500-
fd.set('file1', new File(['hello world'], 'hello.txt', { type: 'text/plain' }) as Blob)
501-
fd.set('file2', new File(['bye world'], 'bye.txt', { type: 'text/plain' }) as Blob)
500+
fd.set('file1', new File(['hello world'], 'hello.txt', { type: 'text/plain' }) as globalThis.File)
501+
fd.set('file2', new File(['bye world'], 'bye.txt', { type: 'text/plain' }) as globalThis.File)
502502

503503
await makeFetch(server)('/', {
504504
body: fd,
@@ -516,7 +516,7 @@ describe('Limits', () => {
516516

517517
const fd = new FormData()
518518

519-
fd.set('file', new File(['hello world'], 'hello.txt', { type: 'text/plain' }) as Blob)
519+
fd.set('file', new File(['hello world'], 'hello.txt', { type: 'text/plain' }) as globalThis.File)
520520

521521
await makeFetch(server)('/', {
522522
body: fd,
@@ -536,7 +536,7 @@ describe('Limits', () => {
536536

537537
const fd = new FormData()
538538

539-
fd.set('file', new File(['hello world to everyone'], 'hello.txt', { type: 'text/plain' }) as Blob)
539+
fd.set('file', new File(['hello world to everyone'], 'hello.txt', { type: 'text/plain' }) as globalThis.File)
540540

541541
await makeFetch(server)('/', {
542542
body: fd,

0 commit comments

Comments
 (0)