add tests for property in & property out

This commit is contained in:
Steve-Mcl
2024-04-25 18:14:41 +01:00
parent e45d14f3f4
commit 640b29da10
8 changed files with 343 additions and 16 deletions

View File

@@ -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) {