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
|
|
|
|
2017-10-12 20:44:34 +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()
|
2017-10-12 20:44:34 +00:00
|
|
|
expect(smartCliTestObject).to.be.instanceof(smartcli.Smartcli)
|
|
|
|
})
|
2017-04-22 19:03:28 +00:00
|
|
|
|
|
|
|
tap.test('should add an command', async () => {
|
2017-10-12 20:44:34 +00:00
|
|
|
expect(smartCliTestObject.addCommand('awesome')).to.not.throw()
|
|
|
|
})
|
2017-04-22 19:03:28 +00:00
|
|
|
|
|
|
|
tap.test('should start parsing a standardTask', async () => {
|
2017-10-12 20:44:34 +00:00
|
|
|
expect(smartCliTestObject.standardTask()).to.be.instanceOf(Promise)
|
|
|
|
})
|
2017-04-22 19:03:28 +00:00
|
|
|
|
|
|
|
let hasExecuted: boolean = false
|
2017-04-22 21:16:49 +00:00
|
|
|
|
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
|
|
|
})
|
2017-10-12 20:44:34 +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 () => {
|
2017-10-12 20:44:34 +00:00
|
|
|
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')
|
2017-10-12 20:44:34 +00:00
|
|
|
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()
|
2017-10-12 20:44:34 +00:00
|
|
|
expect(await smartCliTestObject.parseStarted.promise).to.not.throw()
|
|
|
|
})
|
2017-04-23 13:21:08 +00:00
|
|
|
|
|
|
|
tap.start()
|