Skip to content

Commit

Permalink
fix: passing description in UAVariableType/UAObjectType
Browse files Browse the repository at this point in the history
  • Loading branch information
erossignon committed Feb 6, 2022
1 parent 64b82e9 commit 68fc9e4
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 8 deletions.
1 change: 1 addition & 0 deletions packages/node-opcua-address-space/src/namespace_impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1838,6 +1838,7 @@ export class NamespaceImpl implements NamespacePrivate {
const objectType = this.internalCreateNode({
browseName: options.browseName,
displayName: options.displayName,
description: options.description,
eventNotifier: +options.eventNotifier,
isAbstract: !!options.isAbstract,
nodeClass,
Expand Down
32 changes: 24 additions & 8 deletions packages/node-opcua-address-space/test/test_object_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,24 +117,40 @@ describe("testing UAObjectType", () => {
isAbstract: false,
subtypeOf: "BaseObjectType"
});

objType.displayName.toString().should.eql("locale=null text=Some DisplayName");

objType.displayName.toString().should.eql("locale=null text=Some DisplayName");

const instance1 =objType.instantiate({
browseName: "Instance1",
const instance1 = objType.instantiate({
browseName: "Instance1"
});
instance1.displayName.toString().should.eql("locale=null text=Instance1");

const instance2 =objType.instantiate({
const instance2 = objType.instantiate({
browseName: "Instance2",
displayName: "Instance2 DisplayName"
});
instance2.displayName.toString().should.eql("locale=null text=Instance2 DisplayName");


// tslint:disable:no-console
debugLog(objType.toString());

});
});

it("UAObjectType: create should handle description - type 1", () => {
const namespace = addressSpace.getOwnNamespace();
const objectType = namespace.addObjectType({
browseName: "MyObjectType4",
description: "Some Description"
});

objectType.description.toString().should.eql("locale=null text=Some Description");
});
it("UAObjectType: create should handle description - type 2", () => {
const namespace = addressSpace.getOwnNamespace();
const objectType = namespace.addObjectType({
browseName: "MyObjectType5",
description: { text: "Some Description", locale: "en-US" }
});

objectType.description.toString().should.eql("locale=en-US text=Some Description");
});
});
24 changes: 24 additions & 0 deletions packages/node-opcua-address-space/test/test_variable_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,5 +245,29 @@ describe("testing UAVariableType", () => {
debugLog(varType.toString());
;
});
it("UAVariableType: create should handle description - type 1", ()=>{
const namespace = addressSpace.getOwnNamespace();
const varType = namespace.addVariableType({
browseName: "MyVariableType4",
description: "Some Description",
isAbstract: false,
subtypeOf: "BaseVariableType"
});

varType.description.toString().should.eql("locale=null text=Some Description");

});
it("UAVariableType: create should handle description - type 2", ()=>{
const namespace = addressSpace.getOwnNamespace();
const varType = namespace.addVariableType({
browseName: "MyVariableType5",
description: { text: "Some Description", locale: "en-US" },
isAbstract: false,
subtypeOf: "BaseVariableType"
});

varType.description.toString().should.eql("locale=en-US text=Some Description");

});

});

0 comments on commit 68fc9e4

Please sign in to comment.