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

Add test coverage for deleting a flow

This commit is contained in:
Nick O'Leary 2017-05-11 15:39:55 +01:00
parent c0eabf0438
commit c75dc3cc36
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -661,6 +661,26 @@ describe('flows/util', function() {
diffResult.removed.should.have.length(0); diffResult.removed.should.have.length(0);
diffResult.rewired.should.have.length(0); diffResult.rewired.should.have.length(0);
}); });
it('marks a deleted tab as removed', function() {
var config = [{id:"f1",type:"tab",label:"fred"},{id:"n1",type:"test",bar:"b",wires:[["1"]],z:"f1"},
{id:"f2",type:"tab",label:"fred"},{id:"n2",type:"test",bar:"b",wires:[["1"]],z:"f2"}];
var newConfig = clone(config);
newConfig = newConfig.slice(0,2);
var originalConfig = flowUtil.parseConfig(config);
var changedConfig = flowUtil.parseConfig(newConfig);
originalConfig.missingTypes.should.have.length(0);
var diffResult = flowUtil.diffConfigs(originalConfig,changedConfig);
diffResult.added.should.have.length(0);
diffResult.changed.should.have.length(0);
diffResult.removed.sort().should.eql(['f2', 'n2']);
diffResult.rewired.should.have.length(0);
});
it('marks all nodes as added when tab state changes disabled to enabled', function() { it('marks all nodes as added when tab state changes disabled to enabled', function() {
var config = [{id:"1",type:"tab",disabled:true,label:"fred"},{id:"2",type:"test",bar:"b",wires:[["1"]],z:"1"},{id:"3",type:"test"}]; var config = [{id:"1",type:"tab",disabled:true,label:"fred"},{id:"2",type:"test",bar:"b",wires:[["1"]],z:"1"},{id:"3",type:"test"}];
var newConfig = clone(config); var newConfig = clone(config);