smartcli/test/test.ts

46 lines
1.2 KiB
TypeScript
Raw Normal View History

2017-04-22 19:03:28 +00:00
import { tap, expect } from 'tapbundle'
2017-04-22 20:09:51 +00:00
import { Subject } from 'rxjs'
2016-06-10 00:27:04 +00:00
import smartcli = require('../ts/index')
2017-04-22 19:03:28 +00:00
let smartCliTestObject: smartcli.Smartcli
tap.test('should create a new Smartcli', async () => {
smartCliTestObject = new smartcli.Smartcli()
expect(smartCliTestObject).to.be.instanceof(smartcli.Smartcli)
})
2017-04-22 19:03:28 +00:00
tap.test('should add an command', async () => {
expect(smartCliTestObject.addCommand('awesome')).to.not.throw()
})
2017-04-22 19:03:28 +00:00
tap.test('should start parsing a standardTask', async () => {
expect(smartCliTestObject.standardTask()).to.be.instanceOf(Promise)
})
2017-04-22 19:03:28 +00:00
let hasExecuted: boolean = false
2017-04-22 19:03:28 +00:00
tap.test('should accept a command', async () => {
smartCliTestObject.addTrigger('triggerme')
.subscribe(() => {
hasExecuted = true
2016-06-10 02:13:23 +00:00
})
expect(smartCliTestObject.addTrigger('triggerme')).to.be.instanceof(Subject)
})
2017-04-22 20:09:51 +00:00
2017-04-22 19:03:28 +00:00
tap.test('should not have executed yet', async () => {
expect(hasExecuted).to.be.false()
})
2017-04-22 20:09:51 +00:00
2017-04-22 19:03:28 +00:00
tap.test('should execute when triggered', async () => {
smartCliTestObject.trigger('triggerme')
expect(hasExecuted).be.true()
})
2017-04-22 19:03:28 +00:00
2017-04-23 13:21:08 +00:00
tap.test('should start parsing the CLI input', async () => {
2017-04-22 19:03:28 +00:00
smartCliTestObject.startParse()
expect(await smartCliTestObject.parseStarted.promise).to.not.throw()
})
2017-04-23 13:21:08 +00:00
tap.start()