mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Do not rely on the HTML file to identify where nodes are registered from
This commit is contained in:
@@ -114,7 +114,8 @@ describe("red/nodes/registry/loader",function() {
|
||||
registry.addNodeSet.lastCall.args[1].should.not.have.a.property('err');
|
||||
|
||||
nodes.registerType.calledOnce.should.be.true;
|
||||
nodes.registerType.lastCall.args[0].should.eql('test-node-1');
|
||||
nodes.registerType.lastCall.args[0].should.eql('node-red/TestNode1');
|
||||
nodes.registerType.lastCall.args[1].should.eql('test-node-1');
|
||||
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
@@ -162,8 +163,10 @@ describe("red/nodes/registry/loader",function() {
|
||||
registry.addNodeSet.lastCall.args[1].should.not.have.a.property('err');
|
||||
|
||||
nodes.registerType.calledTwice.should.be.true;
|
||||
nodes.registerType.firstCall.args[0].should.eql('test-node-multiple-1a');
|
||||
nodes.registerType.secondCall.args[0].should.eql('test-node-multiple-1b');
|
||||
nodes.registerType.firstCall.args[0].should.eql('node-red/MultipleNodes1');
|
||||
nodes.registerType.firstCall.args[1].should.eql('test-node-multiple-1a');
|
||||
nodes.registerType.secondCall.args[0].should.eql('node-red/MultipleNodes1');
|
||||
nodes.registerType.secondCall.args[1].should.eql('test-node-multiple-1b');
|
||||
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
@@ -212,7 +215,8 @@ describe("red/nodes/registry/loader",function() {
|
||||
registry.addNodeSet.lastCall.args[1].should.not.have.a.property('err');
|
||||
|
||||
nodes.registerType.calledOnce.should.be.true;
|
||||
nodes.registerType.lastCall.args[0].should.eql('test-node-2');
|
||||
nodes.registerType.lastCall.args[0].should.eql('node-red/TestNode2');
|
||||
nodes.registerType.lastCall.args[1].should.eql('test-node-2');
|
||||
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
|
@@ -442,25 +442,25 @@ describe("red/nodes/registry/registry",function() {
|
||||
events.emit.restore();
|
||||
});
|
||||
it('registers a node constructor', function() {
|
||||
typeRegistry.registerNodeConstructor('node-type',TestNodeConstructor);
|
||||
typeRegistry.registerNodeConstructor('node-set','node-type',TestNodeConstructor);
|
||||
events.emit.calledOnce.should.be.true;
|
||||
events.emit.lastCall.args[0].should.eql('type-registered');
|
||||
events.emit.lastCall.args[1].should.eql('node-type');
|
||||
})
|
||||
it('throws error on duplicate node registration', function() {
|
||||
typeRegistry.registerNodeConstructor('node-type',TestNodeConstructor);
|
||||
typeRegistry.registerNodeConstructor('node-set','node-type',TestNodeConstructor);
|
||||
events.emit.calledOnce.should.be.true;
|
||||
events.emit.lastCall.args[0].should.eql('type-registered');
|
||||
events.emit.lastCall.args[1].should.eql('node-type');
|
||||
/*jshint immed: false */
|
||||
(function(){
|
||||
typeRegistry.registerNodeConstructor('node-type',TestNodeConstructor);
|
||||
typeRegistry.registerNodeConstructor('node-set','node-type',TestNodeConstructor);
|
||||
}).should.throw("node-type already registered");
|
||||
events.emit.calledOnce.should.be.true;
|
||||
});
|
||||
it('extends a constructor with the Node constructor', function() {
|
||||
TestNodeConstructor.prototype.should.not.be.an.instanceOf(Node);
|
||||
typeRegistry.registerNodeConstructor('node-type',TestNodeConstructor);
|
||||
typeRegistry.registerNodeConstructor('node-set','node-type',TestNodeConstructor);
|
||||
TestNodeConstructor.prototype.should.be.an.instanceOf(Node);
|
||||
});
|
||||
it('does not override a constructor\'s prototype', function() {
|
||||
@@ -469,12 +469,12 @@ describe("red/nodes/registry/registry",function() {
|
||||
TestNodeConstructor.prototype.should.be.an.instanceOf(Foo);
|
||||
TestNodeConstructor.prototype.should.not.be.an.instanceOf(Node);
|
||||
|
||||
typeRegistry.registerNodeConstructor('node-type',TestNodeConstructor);
|
||||
typeRegistry.registerNodeConstructor('node-set','node-type',TestNodeConstructor);
|
||||
|
||||
TestNodeConstructor.prototype.should.be.an.instanceOf(Node);
|
||||
TestNodeConstructor.prototype.should.be.an.instanceOf(Foo);
|
||||
|
||||
typeRegistry.registerNodeConstructor('node-type2',TestNodeConstructor);
|
||||
typeRegistry.registerNodeConstructor('node-set','node-type2',TestNodeConstructor);
|
||||
TestNodeConstructor.prototype.should.be.an.instanceOf(Node);
|
||||
TestNodeConstructor.prototype.should.be.an.instanceOf(Foo);
|
||||
});
|
||||
|
Reference in New Issue
Block a user