UNPKG

@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)

57 lines 3.34 kB
"use strict"; 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 sdk_1 = require("../src/api/sdk"); const notification_data_template_1 = require("../src/api/sdk/notification-v4/notification-data-template"); const utils_1 = require("../src/api/utils"); const test_utils_1 = require("./test-utils"); chai.should(); describe("[SDK] NotificationClient", () => { const auth = (0, utils_1.loadAuth)(); const sdk = new sdk_1.MindSphereSdk(Object.assign(Object.assign({}, auth), { basicAuth: (0, utils_1.decrypt)(auth, (0, test_utils_1.getPasskeyForUnitTest)()) })); it("SDK should not be undefined @sanity", () => __awaiter(void 0, void 0, void 0, function* () { sdk.should.not.be.undefined; })); it("Notification Client should not be undefined @sanity", () => __awaiter(void 0, void 0, void 0, function* () { sdk.GetNotificationClientV4().should.not.be.undefined; })); it("should create a simple email template @sanity", () => __awaiter(void 0, void 0, void 0, function* () { const result = (0, notification_data_template_1.notificationTemplate)({ subject: "test subject", message: "test message", fromApplication: "cli", priority: sdk_1.NotificationModelsV4.MulticastEmailNotificationRequestMetadata.PriorityEnum.Normal, recipients: ["sn0wcat@mindsphere.io"], }); result.startsWith("----mindsphere\r\n").should.be.true; result.endsWith("\r\n----mindsphere--").should.be.true; })); it("should create an email template with attachements @sanity", () => __awaiter(void 0, void 0, void 0, function* () { const result = (0, notification_data_template_1.notificationTemplate)({ subject: "test subject", message: "test message", fromApplication: "cli", priority: sdk_1.NotificationModelsV4.MulticastEmailNotificationRequestMetadata.PriorityEnum.Normal, recipients: ["sn0wcat@mindsphere.io"], }, [ { fileName: "upload.txt", buffer: Buffer.from("some-text"), mimeType: "text/plain" }, { fileName: "upload2.txt", buffer: Buffer.from("some-text-2"), mimeType: "text/plain" }, ]); // console.log(result); result.startsWith("----mindsphere\r\n").should.be.true; result.indexOf("\r\nsome-text").should.be.greaterThan(0); result.indexOf("\r\nsome-text-2").should.be.greaterThan(0); result.endsWith("\r\n----mindsphere--").should.be.true; })); }); //# sourceMappingURL=notification-v4.spec.js.map