47 lines
3.9 KiB
JavaScript
47 lines
3.9 KiB
JavaScript
"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,eyJ2ZXJzaW9uIjozLCJmaWxlI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