mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
add tests for property in & property out
This commit is contained in:
@@ -1239,11 +1239,12 @@ describe('file Nodes', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('should be loaded', function(done) {
|
||||
it('should load with defaults', function(done) {
|
||||
var flow = [{id:"fileInNode1", type:"file in", name: "fileInNode", "filename":fileToTest, "format":"utf8"}];
|
||||
helper.load(fileNode, flow, function() {
|
||||
var n1 = helper.getNode("fileInNode1");
|
||||
n1.should.have.property('name', 'fileInNode');
|
||||
n1.should.have.property('propertyOut', 'payload')
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -1530,6 +1531,23 @@ describe('file Nodes', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('should read in a file and output to the message property specified in `propertyOut`', function (done) {
|
||||
const flow = [{ id: "fileInNode1", type: "file in", name: "fileInNode", "filename": fileToTest, "format": "", propertyOut: "file-data", wires: [["n2"]] },
|
||||
{ id: "n2", type: "helper" }]
|
||||
helper.load(fileNode, flow, function () {
|
||||
const n1 = helper.getNode("fileInNode1")
|
||||
const n2 = helper.getNode("n2")
|
||||
n2.on("input", function (msg) {
|
||||
msg.should.have.property('file-data')
|
||||
Buffer.isBuffer(msg['file-data']).should.be.true()
|
||||
msg['file-data'].should.have.length(40)
|
||||
msg['file-data'].toString().should.equal('File message line 1\nFile message line 2\n')
|
||||
done()
|
||||
})
|
||||
n1.receive({ payload: "" })
|
||||
})
|
||||
})
|
||||
|
||||
describe('encodings', function() {
|
||||
|
||||
function checkReadWithEncoding(enc, data, done) {
|
||||
|
Reference in New Issue
Block a user