smartshell/test/test.ts

41 lines
1.2 KiB
TypeScript
Raw Normal View History

2017-02-12 12:13:08 +00:00
import 'typings-test'
import { expect } from 'smartchai'
2017-03-08 15:51:02 +00:00
import * as smartshell from '../dist/index'
2017-03-10 21:08:04 +00:00
let testSmartshell: smartshell.Smartshell
2017-03-10 19:14:40 +00:00
describe('smartshell', function () {
it('it should run async', function () {
this.timeout(1000000)
return smartshell.exec('npm -v').then((execResult) => {
expect(execResult.stdout).to.match(/[0-9\.]*/)
2017-03-08 15:51:02 +00:00
})
2017-03-10 19:14:40 +00:00
})
2017-03-10 21:08:04 +00:00
it('should run async and silent', function () {
2017-03-10 19:14:40 +00:00
return smartshell.execSilent('npm -v').then((execResult) => {
expect(execResult.stdout).to.match(/[0-9\.]*/)
})
})
2017-03-10 21:08:04 +00:00
it('should stream a shell execution', function () {
2017-03-10 19:14:40 +00:00
let execStreamingResponse = smartshell.execStreaming('npm -v')
execStreamingResponse.childProcess.stdout.on('data', (data) => {
console.log('Received ' + data)
})
return execStreamingResponse.finalPromise
})
2017-03-10 21:08:04 +00:00
it('should create a Smartshell instance', function () {
testSmartshell = new smartshell.Smartshell({
executor: 'bash',
sourceFilePaths: []
})
expect(testSmartshell).to.be.instanceof(smartshell.Smartshell)
})
2017-03-11 00:58:09 +00:00
it('should run async', function () {
return testSmartshell.execSilent('sleep 1 && npm -v').then(async (execResult) => {
console.log(execResult.stdout)
})
})
2017-03-10 19:14:40 +00:00
})