Skip to content

Commit

Permalink
tests: add test to confirm issue
Browse files Browse the repository at this point in the history
  • Loading branch information
GrosSacASac committed Aug 25, 2023
1 parent d4f82bc commit d9c8608
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test-node/standalone/multipart_parser.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {Readable} from 'node:stream';
import MultipartParser from '../../src/parsers/Multipart.js';
import {malformedMultipart} from '../../src/FormidableError.js';

import test from 'node:test';
import assert, { deepEqual } from 'node:assert';



test('MultipartParser does not hang', async (t) => {
const mime = `--_\r\n--_--\r\n`;
const parser = new MultipartParser();
parser.initWithBoundary('_');
try {
for await (const {name, buffer, start, end} of Readable.from(mime).pipe(parser)) {
console.log(name, buffer ? buffer.subarray(start, end).toString() : '');
}

} catch (e) {
deepEqual(e.code, malformedMultipart)
return;
// console.error('error');
// console.error(e);

}
assert(false, 'should catch error');
});

0 comments on commit d9c8608

Please sign in to comment.