This commit is contained in:
PhilKunz External
2017-06-27 08:28:11 +00:00
parent 92d26a574c
commit 63d5fe4f1c
9 changed files with 31 additions and 69 deletions

1
test/test.d.ts vendored
View File

@ -1 +0,0 @@
import 'typings-test';

View File

@ -1,47 +0,0 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
require("typings-test");
const smartchai_1 = require("smartchai");
const smartshell = require("../dist/index");
let testSmartshell;
describe('smartshell', function () {
it('it should run async', function () {
this.timeout(1000000);
return smartshell.exec('npm -v').then((execResult) => {
smartchai_1.expect(execResult.stdout).to.match(/[0-9\.]*/);
});
});
it('should run async and silent', function () {
return smartshell.execSilent('npm -v').then((execResult) => {
smartchai_1.expect(execResult.stdout).to.match(/[0-9\.]*/);
});
});
it('should stream a shell execution', function () {
let execStreamingResponse = smartshell.execStreaming('npm -v');
execStreamingResponse.childProcess.stdout.on('data', (data) => {
console.log('Received ' + data);
});
return execStreamingResponse.finalPromise;
});
it('should create a Smartshell instance', function () {
testSmartshell = new smartshell.Smartshell({
executor: 'bash',
sourceFilePaths: []
});
smartchai_1.expect(testSmartshell).to.be.instanceof(smartshell.Smartshell);
});
it('should run async', function () {
return testSmartshell.execSilent('sleep 1 && npm -v').then((execResult) => __awaiter(this, void 0, void 0, function* () {
console.log(execResult.stdout);
}));
});
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI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FBQyxDQUFBO1FBQ2pDLENBQUMsQ0FBQyxDQUFBO1FBQ0YsTUFBTSxDQUFDLHFCQUFxQixDQUFDLFlBQVksQ0FBQTtJQUMzQyxDQUFDLENBQUMsQ0FBQTtJQUNGLEVBQUUsQ0FBQyxxQ0FBcUMsRUFBRTtRQUN4QyxjQUFjLEdBQUcsSUFBSSxVQUFVLENBQUMsVUFBVSxDQUFDO1lBQ3pDLFFBQVEsRUFBRSxNQUFNO1lBQ2hCLGVBQWUsRUFBRSxFQUFFO1NBQ3BCLENBQUMsQ0FBQTtRQUNGLGtCQUFNLENBQUMsY0FBYyxDQUFDLENBQUMsRUFBRSxDQUFDLEVBQUUsQ0FBQyxVQUFVLENBQUMsVUFBVSxDQUFDLFVBQVUsQ0FBQyxDQUFBO0lBQ2hFLENBQUMsQ0FBQyxDQUFBO0lBRUYsRUFBRSxDQUFDLGtCQUFrQixFQUFFO1FBQ3JCLE1BQU0sQ0FBQyxjQUFjLENBQUMsVUFBVSxDQUFDLG1CQUFtQixDQUFDLENBQUMsSUFBSSxDQUFDLENBQU8sVUFBVTtZQUMxRSxPQUFPLENBQUMsR0FBRyxDQUFDLFVBQVUsQ0FBQyxNQUFNLENBQUMsQ0FBQTtRQUNoQyxDQUFDLENBQUEsQ0FBQyxDQUFBO0lBQ0osQ0FBQyxDQUFDLENBQUE7QUFDSixDQUFDLENBQUMsQ0FBQSJ9

View File

@ -1,28 +1,37 @@
import { expect, tap } from 'tapbundle'
import * as smartshell from '../dist/index'
import * as smartq from 'smartq'
let testSmartshell: smartshell.Smartshell
tap.test('smartshell should run async', async () => {
this.timeout(1000000)
return smartshell.exec('npm -v').then((execResult) => {
expect(execResult.stdout).to.match(/[0-9\.]*/)
})
let execResult = await smartshell.exec('npm -v')
expect(execResult.stdout).to.match(/[0-9\.]*/)
})
tap.test('smartshell should run async and silent', async () => {
return smartshell.execSilent('npm -v').then((execResult) => {
expect(execResult.stdout).to.match(/[0-9\.]*/)
})
let execResult = await smartshell.execSilent('npm -v')
expect(execResult.stdout).to.match(/[0-9\.]*/)
})
tap.test('smartshell should stream a shell execution', async () => {
let done = smartq.defer()
let execStreamingResponse = smartshell.execStreaming('npm -v')
execStreamingResponse.childProcess.stdout.on('data', (data) => {
console.log('Received ' + data)
execStreamingResponse.childProcess.stdout.on('data', data => {
done.resolve(data)
})
return execStreamingResponse.finalPromise
let data = await done.promise
expect(data).to.equal('5.0.3\n')
await execStreamingResponse.finalPromise
})
tap.test('it should execute and wait for a line in the output', async () => {
await smartshell.execAndWaitForLine('npm -v', /5.0.3/)
})
// Smartshell class
tap.test('smartshell should create a Smartshell instance', async () => {
testSmartshell = new smartshell.Smartshell({
executor: 'bash',