UNPKG

@hkvstore/taco-cli

Version:

taco-cli is a command-line interface for rapid Apache Cordova development (forked from Microsoft taco-cli)

79 lines (77 loc) 2.91 kB
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for details. /// <reference path="../../typings/should.d.ts"/> /// <reference path="../../typings/mocha.d.ts"/> /// <reference path="../../typings/tacoUtils.d.ts"/> "use strict"; var fs = require("fs"); var path = require("path"); var should = require("should"); var Taco = require("../cli/taco"); var tacoUtils = require("taco-utils"); var Version = require("../cli/version"); var CommandHelper = require("./utils/commandHelper"); var TacoUtilsErrorCodes = tacoUtils.TacoErrorCode; // Command list var commandsJsonPath = path.resolve(__dirname, "..", "cli", "commands.json"); fs.existsSync(commandsJsonPath).should.be.true; var commands = require(commandsJsonPath); should(commands).not.be.empty; // Options we are interested in testing var tacoValidArgs = [[], ["-v"], ["--help"], ["-----help"]]; var tacoInvalidArgs = [["/?"], ["?"]]; function runHelp(command) { var help = CommandHelper.getCommand("help"); return help.run([command]); } ; function runVersion() { var version = new Version(); return version.run([]); } ; describe("taco meta command tests: ", function () { // Run help for a cordova command not overriden by taco - ex, "info" it("taco help info executes with no error", function (done) { runHelp("info").then(function () { done(); }, function (err) { done(err); }); }); // Run taco command with valid and invalid options describe("taco command", function () { tacoValidArgs.forEach(function (optionString) { it("with options " + optionString + " executes with no error", function (done) { Taco.runWithArgs(optionString).then(function () { done(); }, function (err) { done(err); }); }); }); tacoInvalidArgs.forEach(function (optionString) { it("with invalid options " + optionString + " executes with expected error", function (done) { Taco.runWithArgs(optionString).then(function () { done(new Error("Passing Invalid options to \'taco\' should have failed")); }, function (err) { if (err.errorCode === TacoUtilsErrorCodes.CordovaCommandFailed) { done(); } else { done(new Error("Unexpected error code")); } }); }); }); }); // Run taco version command it("taco version command should execute without an error", function (done) { runVersion().then(function () { done(); }, function (err) { done(err); }); }); }); //# sourceMappingURL=meta.js.map