Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1341 from rwky/formdata-error
Emit FormData error events as Request error events
- Loading branch information
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use strict' | ||
|
||
var request = require('../index') | ||
, server = require('./server') | ||
, tape = require('tape') | ||
|
||
var s = server.createServer() | ||
|
||
tape('setup', function(t) { | ||
s.listen(s.port, function() { | ||
t.end() | ||
}) | ||
}) | ||
|
||
tape('re-emit formData errors', function(t) { | ||
s.on('/', function(req, res) { | ||
res.writeHead(400) | ||
res.end() | ||
t.fail('The form-data error did not abort the request.') | ||
}) | ||
|
||
request.post(s.url, function (err, res, body) { | ||
t.equal(err.message, 'form-data: Arrays are not supported.') | ||
setTimeout(function() { | ||
t.end() | ||
}, 10) | ||
}).form().append('field', ['value1', 'value2']) | ||
}) | ||
|
||
tape('cleanup', function(t) { | ||
s.close(function() { | ||
t.end() | ||
}) | ||
}) |