UNPKG

@hkvstore/taco-cli

Version:

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

74 lines (72 loc) 3.37 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/mocha.d.ts"/> /// <reference path="../../typings/should.d.ts"/> /// <reference path="../../typings/tacoUtils.d.ts"/> /// <reference path="../../typings/tacoKits.d.ts"/> /// <reference path="../../typings/tacoTestsUtils.d.ts"/> "use strict"; /* tslint:disable:no-var-requires */ // var require needed for should module to work correctly // Note not import: We don't want to refer to shouldModule, but we need the require to occur since it modifies the prototype of Object. var shouldModule = require("should"); /* tslint:enable:no-var-requires */ /* tslint:disable:no-var-requires */ // Special case to allow using color package with index signature for style rules var colors = require("colors/safe"); /* tslint:enable:no-var-requires */ var os = require("os"); var path = require("path"); var Templates = require("../cli/templates"); var tacoTestsUtils = require("taco-tests-utils"); var MemoryStream = tacoTestsUtils.MemoryStream; describe("templates", function () { function templatesRun() { var templates = new Templates(); return templates.run([]); } var previous; before(function () { previous = process.env["TACO_UNIT_TEST"]; process.env["TACO_UNIT_TEST"] = true; var tacoHome = path.join(os.tmpdir(), "taco-cli", "templates"); // Use a dummy home location so we don't trash any real configurations process.env["TACO_HOME"] = tacoHome; }); after(function () { process.env["TACO_UNIT_TEST"] = previous; }); it("'taco templates' should not throw any error", function (done) { templatesRun().then(done, done); }); describe("Onboarding experience", function () { // because of function overloading assigning "(buffer: string, cb?: Function) => boolean" as the type for // stdoutWrite just doesn't work var stdoutWrite = process.stdout.write; // We save the original implementation, so we can restore it later var memoryStdout; beforeEach(function () { memoryStdout = new MemoryStream; // Each individual test gets a new and empty console process.stdout.write = memoryStdout.writeAsFunction(); // We'll be printing into an "in-memory" console, so we can test the output }); after(function () { // We just need to reset the stdout just once, after all the tests have finished process.stdout.write = stdoutWrite; }); it("templates prints the onboarding experience", function (done) { templatesRun().done(function () { var expected = [ "CommandTemplatesHeader", "", " blank ............... BlankTemplateName", " typescript .......... TypescriptTemplateName", "", "HowToUseCreateProjectWithTemplate", ""].join("\n"); var actual = colors.strip(memoryStdout.contentsAsText()); // The colors add extra characters actual.should.be.equal(expected); done(); }, done); }); }); }); //# sourceMappingURL=templates.js.map