UNPKG

teamsfx-extension

Version:

Create, debug, and deploy Teams apps with Teams Toolkit

129 lines 5.2 kB
// Copyright (c) Microsoft Corporation. // Licensed under the MIT license. "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 }); exports.TestUserInput = exports.EInputType = void 0; const chai = require("chai"); const vscode_1 = require("vscode"); const globalVaribles_1 = require("./globalVaribles"); var EInputType; (function (EInputType) { EInputType["defaultValue"] = "defaultValue"; EInputType["specifiedItem"] = "specifiedItem"; EInputType["specifiedValue"] = "specifiedValue"; })(EInputType = exports.EInputType || (exports.EInputType = {})); class TestUserInput { constructor() { this.workspace = globalVaribles_1.testFolder; this.inputs = []; } addInputItems(items) { this.inputs.push(...items); } setWorkspace(workspace) { this.workspace = workspace; } getInputItem() { const input = this.inputs.shift(); return input || { type: EInputType.defaultValue }; } showQuickPick(items, options) { return __awaiter(this, void 0, void 0, function* () { const resolvedItems = yield Promise.resolve(items); const input = this.getInputItem(); if (!input) { return undefined; } else { switch (input.type) { case EInputType.defaultValue: return resolvedItems[0]; case EInputType.specifiedItem: chai.assert(typeof input.index === "number", "[Mock] error: input.index must be number if specify the item!"); return resolvedItems[input.index || 0]; case EInputType.specifiedValue: return input.value; } } }); } showInputBox(options) { return __awaiter(this, void 0, void 0, function* () { const input = this.getInputItem(); if (!input) { return undefined; } else { switch (input.type) { case EInputType.defaultValue: return options.value; case EInputType.specifiedItem: chai.assert(typeof input.index === "string", "[Mock] error: input.index must be string if specify the item!"); return options[input.index || ""]; case EInputType.specifiedValue: return input.value; } } }); } showOpenDialog(options) { return __awaiter(this, void 0, void 0, function* () { const input = this.getInputItem(); if (!input) { return undefined; } else { switch (input.type) { case EInputType.defaultValue: return [vscode_1.Uri.file(this.workspace)]; case EInputType.specifiedItem: chai.assert(false, "[Mock] error: open dialog can't specify the item!"); return undefined; case EInputType.specifiedValue: return input.value ? [vscode_1.Uri.file(input.value)] : undefined; } } }); } openFolder(uri) { return __awaiter(this, void 0, void 0, function* () { return uri.fsPath; }); } showInformationMessage(message, ...items) { return __awaiter(this, void 0, void 0, function* () { return yield vscode_1.window.showInformationMessage(message, ...items); }); } showWarningMessage(message, ...items) { return __awaiter(this, void 0, void 0, function* () { return yield vscode_1.window.showWarningMessage(message, ...items); }); } showErrorMessage(message, ...items) { return __awaiter(this, void 0, void 0, function* () { return yield vscode_1.window.showErrorMessage(message, ...items); }); } openExternal(link) { return __awaiter(this, void 0, void 0, function* () { return vscode_1.env.openExternal(link); }); } withProgress(options, task) { return __awaiter(this, void 0, void 0, function* () { return yield vscode_1.window.withProgress(options, task); }); } } exports.TestUserInput = TestUserInput; //# sourceMappingURL=testUserInput.js.map