Skip to content
This repository was archived by the owner on Apr 29, 2020. It is now read-only.

Commit d877ff6

Browse files
committed
refactor: refactor clunky test
1 parent 4155796 commit d877ff6

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

test/parser.spec.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -118,20 +118,19 @@ describe('parser', () => {
118118
})
119119

120120
it('parses multipart requests with metatdata correctly', (done) => {
121-
const r = request.post({ url: `http://localhost:${PORT}` }, (err) => done(err))
122-
123-
// request uses an old version of form-data so this is clunky
124-
const CRLF = '\r\n'
125-
const form = r.form()
126-
form.append('file', fileContent, {
127-
header: [
128-
`--${form.getBoundary()}`,
129-
'content-type: application/octet-stream',
130-
'content-disposition: form-data; filename="file.txt"; name="file"',
131-
`mtime: ${fileMtime}`,
132-
`mode: ${fileMode}`
133-
].join(CRLF) + CRLF
134-
})
121+
const formData = {
122+
file: {
123+
value: fileContent,
124+
options: {
125+
header: {
126+
mtime: fileMtime,
127+
mode: fileMode
128+
}
129+
}
130+
}
131+
}
132+
133+
request.post({ url: `http://localhost:${PORT}`, formData }, (err) => done(err))
135134
})
136135
})
137136

0 commit comments

Comments
 (0)