@mindconnect/mindconnect-nodejs
Version:
NodeJS Library for Siemens Insights Hub Connectivity - TypeScript SDK for Insights Hub and Industrial IoT - Command Line Interface - Insights Hub Development Proxy (Siemens Insights Hub was formerly known as MindSphere)
102 lines • 5.32 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const chai = require("chai");
require("url-search-params-polyfill");
const src_1 = require("../src");
const utils_1 = require("../src/api/utils");
const test_device_setup_utils_1 = require("./test-device-setup-utils");
const test_utils_1 = require("./test-utils");
chai.should();
describe.skip("[SDK] DeviceManagementClient.DeviceTypes", () => {
const auth = (0, utils_1.loadAuth)();
const sdk = new src_1.MindSphereSdk(Object.assign(Object.assign({}, auth), { basicAuth: (0, utils_1.decrypt)(auth, (0, test_utils_1.getPasskeyForUnitTest)()) }));
const deviceManagementClient = sdk.GetDeviceManagementClient();
const tenant = sdk.GetTenant();
const testDeviceType = {
name: `${tenant}.UnitTestDeviceType`,
code: `${tenant}.V001`,
assetTypeId: `${tenant}.UnitTestDeviceAssetType`,
description: " example device type",
properties: {
key1: "value1",
key2: "value2",
},
};
let deviceTypeId = "aee2e37f-f562-4ed6-b90a-c43208dc054a";
let assetTypeId = `${tenant}.UnitTestDeviceAssetType`;
let assetId = "";
let deviceId = "";
let gFolderid = "";
before(() => __awaiter(void 0, void 0, void 0, function* () {
// tear Down test infrastructure
yield (0, test_device_setup_utils_1.tearDownDeviceTestStructure)(sdk);
// Setup the testing architecture
const { device, deviceAsset, deviceType, deviceAssetType, folderid } = yield (0, test_device_setup_utils_1.setupDeviceTestStructure)(sdk);
assetTypeId = `${deviceAssetType.id}`;
deviceTypeId = `${deviceType.id}`;
assetId = `${deviceAsset.id}`;
deviceId = `${device.id}`;
gFolderid = `${folderid}`;
}));
after(() => __awaiter(void 0, void 0, void 0, function* () {
// tear Down test infrastructure
yield (0, test_device_setup_utils_1.tearDownDeviceTestStructure)(sdk);
}));
it("SDK should not be undefined", () => __awaiter(void 0, void 0, void 0, function* () {
sdk.should.not.be.undefined;
}));
it("standard properties shoud be defined", () => __awaiter(void 0, void 0, void 0, function* () {
deviceManagementClient.should.not.be.undefined;
deviceManagementClient.GetGateway().should.be.equal(auth.gateway);
(yield deviceManagementClient.GetToken()).length.should.be.greaterThan(200);
(yield deviceManagementClient.GetToken()).length.should.be.greaterThan(200);
}));
it("should GET device types @sanity", () => __awaiter(void 0, void 0, void 0, function* () {
deviceManagementClient.should.not.be.undefined;
const deviceTypes = yield deviceManagementClient.GetDeviceTypes({
assetTypeId: `${tenant}.UnitTestDeviceAssetType`,
owner: `${tenant}`,
});
deviceTypes.should.not.be.undefined;
deviceTypes.should.not.be.null;
deviceTypes.page.number.should.equal(0);
deviceTypes.page.size.should.equal(10);
deviceTypes.content.length.should.be.gte(1);
}));
it("should GET device types with sorting", () => __awaiter(void 0, void 0, void 0, function* () {
deviceManagementClient.should.not.be.undefined;
const deviceTypes = yield deviceManagementClient.GetDeviceTypes({
assetTypeId: `${tenant}.UnitTestDeviceAssetType`,
owner: `${tenant}`,
sort: "DESC",
page: 0,
size: 0,
});
deviceTypes.should.not.be.undefined;
deviceTypes.should.not.be.null;
deviceTypes.content || (0, utils_1.throwError)("there have to be some devicetypes with that sort parameter!");
deviceTypes.content.length.should.be.greaterThan(0);
}));
it("should GET specific device type ", () => __awaiter(void 0, void 0, void 0, function* () {
deviceManagementClient.should.not.be.undefined;
const deviceType = yield deviceManagementClient.GetDeviceType(deviceTypeId);
deviceType.should.not.be.null;
}));
it("should PATCH specific device type ", () => __awaiter(void 0, void 0, void 0, function* () {
deviceManagementClient.should.not.be.undefined;
testDeviceType.name = `${tenant}.UnitTestDeviceType_B`;
const patchedDeviceType = yield deviceManagementClient.PatchDeviceType(deviceTypeId, testDeviceType);
patchedDeviceType.should.not.be.null;
patchedDeviceType.name.should.be.string(`${tenant}.UnitTestDeviceType_B`);
}));
});
//# sourceMappingURL=oe-device-management-device-types.spec.js.map