add parts support for HTML node (#1495)

* add parts support for HTML node

* add parts.{type,ch} to output of HTML node
This commit is contained in:
Hiroyasu Nishiyama
2017-12-01 22:09:05 +09:00
committed by Dave Conway-Jones
parent b9213b73bd
commit 806457063f
2 changed files with 33 additions and 0 deletions

View File

@@ -207,12 +207,29 @@ describe('html node', function() {
describe('multiple messages', function(){
var cnt = 0;
var parts_id = undefined;
afterEach(function() {
cnt.should.be.exactly(2);
cnt = 0;
parts_id = undefined;
});
function check_parts(msg, index, count) {
msg.should.have.property('parts');
msg.parts.should.have.property('id');
if(parts_id === undefined) {
parts_id = msg.parts.id;
}
else {
msg.parts.should.have.property('id', parts_id);
}
msg.parts.should.have.property('index', index);
msg.parts.should.have.property('count', count);
msg.parts.should.have.property('type', 'string');
msg.parts.should.have.property('ch', '');
}
it('should retrieve list contents as html as default with output as multiple msgs ', function(done) {
fs.readFile(file, 'utf8', function(err, data) {
var flow = [{id:"n1",type:"html",wires:[["n2"]],tag:"ul",as:"multi"},
@@ -224,6 +241,7 @@ describe('html node', function() {
n2.on("input", function(msg) {
cnt++;
msg.should.have.property('topic', 'bar');
check_parts(msg, cnt -1, 2);
if (cnt !== 1 && cnt !== 2) {
return false;
}
@@ -252,6 +270,7 @@ describe('html node', function() {
n2.on("input", function(msg) {
cnt++;
msg.should.have.property('topic', 'bar');
check_parts(msg, cnt -1, 2);
if (cnt !== 1 && cnt !== 2) {
return false;
}
@@ -281,6 +300,7 @@ describe('html node', function() {
msg.should.have.property('payload');
msg.payload.should.have.property('src','foo.png');
msg.should.have.property('topic', 'bar');
check_parts(msg, 0, 1);
cnt = 2; // frig the answer as only one img tag
done();
});