UNPKG

@kwaeri/wizard

Version:

The @kwaeri/wizard component module of the @kwaeri/node-kit platform.

83 lines (82 loc) 4.78 kB
/*----------------------------------------------------------------------------- * @package: node-kit wizard * @author: Richard B Winters * @copyright: 2014-2020 Massively Modified, Inc. * @license: Apache-2.0 <http://www.apache.org/licenses/LICENSE-2.0> * @version: 0.2.0 *---------------------------------------------------------------------------*/ '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 }); // INCLUDES const assert = require("assert"); const wizard_1 = require("../src/wizard"); // SANITY CHECK - Makes sure our tests are working proerly describe('sanity', function () { describe('sanity()', function () { it('Should return true.', function () { assert.equal([1, 2, 3, 4].indexOf(4), 3); }); }); }); // Service CHECK - Make sure the infrastructure is sensible describe('SomeWizardServiceProvider:getServiceProviderSubscriptions', function () { describe('SomeWizardServiceProvider.getServiceProviderSubsctiptions()', function () { it('Should return true.', () => __awaiter(this, void 0, void 0, function* () { let esp = new wizard_1.ExampleWizard(); let testMethodResult = esp.getServiceProviderSubscriptions(); return Promise.resolve(assert.equal(JSON.stringify(testMethodResult), JSON.stringify({ commands: {}, required: {}, optional: {}, subcommands: {} }))); })); }); }); // Service CHECK - Make sure the infrastructure is sensible describe('SomeWizardServiceProvider:getServiceProviderSubscriptionHelpText', function () { describe('SomeWizardServiceProvider.getServiceProviderSubscriptionHelpText()', function () { it('Should return true.', () => __awaiter(this, void 0, void 0, function* () { let esp = new wizard_1.ExampleWizard(); let testMethodResult = esp.getServiceProviderSubscriptionHelpText(); return Promise.resolve(assert.equal(JSON.stringify(testMethodResult), JSON.stringify({ helpText: { "command": "To use this service, read this HelpText." } }))); })); }); }); // Service CHECK - Make sure the infrastructure is sensible describe('SomeWizardServiceProvider:run', function () { describe('SomeWizardServiceProvider.run()', function () { it('Should return true.', () => __awaiter(this, void 0, void 0, function* () { let esp = new wizard_1.ExampleWizard(), testMethodResult = null, answers; if (esp) { console.log('Starting the wizard...'); // Run the wizard, our test will press enter for us, resulting in a null answer that is directly returned // in our promise testMethodResult = yield esp.run({ name: null }); // Pack the answers from the wizard into our variable (we don't have any formatted promises returning, so // expect null - providing this implementation in order to show how we might receive the result from the // wizard when we're packing answers into a formatted promise): answers = (testMethodResult && testMethodResult.answers) ? testMethodResult.answers : { question1Answer: null }; } return Promise.resolve(assert.equal(JSON.stringify(answers), JSON.stringify({ question1Answer: null }))); })); }); }); // Service CHECK - Make sure the infrastructure is sensible describe('SomeWizardServiceProvider:setServiceEventMetadata', function () { describe('SomeWizardServiceProvider.setServiceEventMetadata()', function () { it('Should return true.', () => __awaiter(this, void 0, void 0, function* () { let esp = new wizard_1.ExampleWizard(); esp.testEvents((data) => { return Promise.resolve(assert.equal(JSON.stringify(data), JSON.stringify({ progressLevel: 50, notice: "Complete", log: "Test", logType: 0 }))); }); esp.setServiceEventMetadata({ progressLevel: 50, notice: "Complete", log: "Test", logType: 0 }); })); }); });