Skip to content

Commit

Permalink
expose BaseNode#setDescription #1284
Browse files Browse the repository at this point in the history
  • Loading branch information
erossignon committed Jun 29, 2023
1 parent b3ac8eb commit 472f424
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/node-opcua-address-space-base/source/base_node.ts
Expand Up @@ -7,6 +7,7 @@ import {
AttributeIds,
BrowseDirection,
LocalizedText,
LocalizedTextLike,
NodeClass,
QualifiedName,
QualifiedNameLike,
Expand Down Expand Up @@ -254,4 +255,6 @@ export declare class BaseNode extends EventEmitter {
*
*/
getAggregates(): BaseNode[];

setDescription(description: LocalizedTextLike): void;
}
3 changes: 2 additions & 1 deletion packages/node-opcua-address-space/src/base_node_impl.ts
Expand Up @@ -193,7 +193,8 @@ export class BaseNodeImpl extends EventEmitter implements BaseNode {
return _private._description!;
}

public setDescription(value: LocalizedText): void {
public setDescription(value: LocalizedTextLike): void {

this._setDescription(value);
/**
* fires when the description attribute is changed.
Expand Down
43 changes: 43 additions & 0 deletions packages/node-opcua-address-space/test/test_issue_1284.ts
@@ -0,0 +1,43 @@
import { coerce } from "yargs";
import { AddressSpace } from "..";
import { generateAddressSpace } from "../distNodeJS";
import { get_mini_nodeset_filename } from "../testHelpers";
import "should";
import { coerceLocalizedText } from "node-opcua-data-model";

const mini_nodeset_filename = get_mini_nodeset_filename();

describe("setDescription", () => {
let addressSpace: AddressSpace;

beforeEach(async () => {
addressSpace = AddressSpace.create();
const xml_files = [mini_nodeset_filename];
await generateAddressSpace(addressSpace, xml_files);

addressSpace.registerNamespace("Private");
});
afterEach(() => {
if (addressSpace) {
addressSpace.dispose();
}
});
it("should be possible to change the description of a variable", () => {
const namespace = addressSpace.getOwnNamespace();

const uaVariable = namespace.addVariable({
browseName: "MyVariable",
dataType: "Double",
organizedBy: addressSpace.rootFolder.objects,
description: {locale: "fr", text:"Ma Variable"}
});

uaVariable.description.text!.should.eql("Ma Variable");


uaVariable.setDescription({ locale: "fi", text: "minun muuttujani" });

uaVariable.description.text!.should.eql("minun muuttujani");

});
});

0 comments on commit 472f424

Please sign in to comment.