Skip to content

Commit

Permalink
test(multipart): add tests to actually complete coverage of `split-mu…
Browse files Browse the repository at this point in the history
…ltipart`
  • Loading branch information
Lordfirespeed committed Aug 20, 2024
1 parent 01db681 commit 4f020f1
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/parsers/multipart.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,38 @@ it('should reject multipart form data with non-linear-whitespace characters on a
'epilogue',
].join('\r\n')

expect(() => {
parseMultipart(Buffer.from(multipart), 'boundary')
}).toThrow()
})

it('should reject multipart form data with parts after a close delimiter', () => {
const multipart = [
'preamble',
'--boundary',
'',
'',
'--boundary--',
'',
'',
'--boundary',
'epilogue',
].join('\r\n')

expect(() => {
parseMultipart(Buffer.from(multipart), 'boundary')
}).toThrow()
})

it('should reject multipart form data with non-linear-whitespace characters on a boundary line with no preamble', () => {
const multipart = [
'--boundary eeee',
'',
'',
'--boundary--',
'epilogue',
].join('\r\n')

expect(() => {
parseMultipart(Buffer.from(multipart), 'boundary')
}).toThrow()
Expand Down

0 comments on commit 4f020f1

Please sign in to comment.