update
This commit is contained in:
64
test/test.ts
64
test/test.ts
@ -1,40 +1,40 @@
|
||||
import 'typings-test'
|
||||
import { expect } from 'smartchai'
|
||||
import { expect, tap } from 'tapbundle'
|
||||
|
||||
import * as smartshell from '../dist/index'
|
||||
|
||||
let testSmartshell: smartshell.Smartshell
|
||||
|
||||
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\.]*/)
|
||||
})
|
||||
})
|
||||
it('should run async and silent', function () {
|
||||
return smartshell.execSilent('npm -v').then((execResult) => {
|
||||
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: []
|
||||
})
|
||||
expect(testSmartshell).to.be.instanceof(smartshell.Smartshell)
|
||||
})
|
||||
|
||||
it('should run async', function () {
|
||||
return testSmartshell.execSilent('sleep 1 && npm -v').then(async (execResult) => {
|
||||
console.log(execResult.stdout)
|
||||
})
|
||||
tap.test('smartshell should run async', async () => {
|
||||
this.timeout(1000000)
|
||||
return smartshell.exec('npm -v').then((execResult) => {
|
||||
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\.]*/)
|
||||
})
|
||||
})
|
||||
tap.test('smartshell should stream a shell execution', async () => {
|
||||
let execStreamingResponse = smartshell.execStreaming('npm -v')
|
||||
execStreamingResponse.childProcess.stdout.on('data', (data) => {
|
||||
console.log('Received ' + data)
|
||||
})
|
||||
return execStreamingResponse.finalPromise
|
||||
})
|
||||
tap.test('smartshell should create a Smartshell instance', async () => {
|
||||
testSmartshell = new smartshell.Smartshell({
|
||||
executor: 'bash',
|
||||
sourceFilePaths: []
|
||||
})
|
||||
expect(testSmartshell).to.be.instanceof(smartshell.Smartshell)
|
||||
})
|
||||
|
||||
tap.test('smartshell should run async', async () => {
|
||||
return testSmartshell.execSilent('sleep 1 && npm -v').then(async (execResult) => {
|
||||
console.log(execResult.stdout)
|
||||
})
|
||||
})
|
||||
|
||||
tap.start()
|
||||
|
Reference in New Issue
Block a user