1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Add tests

This commit is contained in:
Ben Hardill 2022-12-24 20:35:51 +00:00
parent 5670bd8265
commit 661b07c856
No known key found for this signature in database
GPG Key ID: 74DD076979ABB1E7

View File

@ -2322,7 +2322,7 @@ describe('HTTP Request Node', function() {
var n2 = helper.getNode("n2"); var n2 = helper.getNode("n2");
n2.on('input', function(msg) { n2.on('input', function(msg) {
try{ try{
msg.payload.should.equal(`RequestError: Parse Error: Missing expected CR after header value : http://localhost:${port}/`) msg.payload.should.startWith(`RequestError: Parse Error:`)
done() done()
} catch (err) { } catch (err) {
done(err) done(err)
@ -2334,4 +2334,38 @@ describe('HTTP Request Node', function() {
}); });
} }
}); });
describe('multipart form posts', function() {
it('should send arrays as multiple entries', function (done) {
const flow = [
{
id: 'n1', type: 'http request', wires: [['n2']], method: 'POST', ret: 'obj', url: getTestURL('/file-upload'), headers: [
]
},
{ id: "n2", type: "helper" }
];
helper.load(httpRequestNode, flow, function() {
var n1 = helper.getNode("n1");
var n2 = helper.getNode("n2");
n2.on('input', function(msg){
try {
msg.payload.body.should.have.property('foo')
msg.payload.body.list.should.deepEqual(['a','b','c'])
done()
} catch (e) {
done(e)
}
});
n1.receive({
headers: {
'content-type': 'multipart/form-data'
},
payload: {
foo: 'bar',
list: [ 'a', 'b', 'c' ]
}
});
})
});
})
}); });