fix tests and add .triggerOnlyOnProcessEnvCliCall()
This commit is contained in:
31
test/test.ts
31
test/test.ts
@ -1,23 +1,22 @@
|
||||
import { tap, expect } from 'tapbundle'
|
||||
import { Subject } from 'rxjs'
|
||||
|
||||
import smartcli = require('../dist/index')
|
||||
import smartcli = require('../ts/index')
|
||||
|
||||
let smartCliTestObject: smartcli.Smartcli
|
||||
|
||||
tap.test('should create a new Smartcli', async () => {
|
||||
smartCliTestObject = new smartcli.Smartcli()
|
||||
return expect(smartCliTestObject).be.instanceof(smartcli.Smartcli)
|
||||
}).catch(tap.threw)
|
||||
expect(smartCliTestObject).to.be.instanceof(smartcli.Smartcli)
|
||||
})
|
||||
|
||||
tap.test('should add an command', async () => {
|
||||
return expect(smartCliTestObject.addCommand('awesome')).to.not.throw
|
||||
}).catch(tap.threw)
|
||||
|
||||
expect(smartCliTestObject.addCommand('awesome')).to.not.throw()
|
||||
})
|
||||
|
||||
tap.test('should start parsing a standardTask', async () => {
|
||||
return expect(smartCliTestObject.standardTask()).to.be.instanceOf(Promise)
|
||||
}).catch(tap.threw)
|
||||
expect(smartCliTestObject.standardTask()).to.be.instanceOf(Promise)
|
||||
})
|
||||
|
||||
let hasExecuted: boolean = false
|
||||
|
||||
@ -26,21 +25,21 @@ tap.test('should accept a command', async () => {
|
||||
.subscribe(() => {
|
||||
hasExecuted = true
|
||||
})
|
||||
return expect(smartCliTestObject.addTrigger('triggerme')).to.be.instanceof(Subject)
|
||||
}).catch(tap.threw)
|
||||
expect(smartCliTestObject.addTrigger('triggerme')).to.be.instanceof(Subject)
|
||||
})
|
||||
|
||||
tap.test('should not have executed yet', async () => {
|
||||
return expect(hasExecuted).to.be.false
|
||||
}).catch(tap.threw)
|
||||
expect(hasExecuted).to.be.false()
|
||||
})
|
||||
|
||||
tap.test('should execute when triggered', async () => {
|
||||
smartCliTestObject.trigger('triggerme')
|
||||
return expect(hasExecuted).be.true
|
||||
}).catch(tap.threw)
|
||||
expect(hasExecuted).be.true()
|
||||
})
|
||||
|
||||
tap.test('should start parsing the CLI input', async () => {
|
||||
smartCliTestObject.startParse()
|
||||
return await expect(smartCliTestObject.parseStarted.promise).to.eventually.be.fulfilled
|
||||
}).catch(tap.threw)
|
||||
expect(await smartCliTestObject.parseStarted.promise).to.not.throw()
|
||||
})
|
||||
|
||||
tap.start()
|
||||
|
Reference in New Issue
Block a user