smartcli/test/test.ts

45 lines
1.4 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
2016-10-14 23:06:36 +00:00
import smartcli = require('../dist/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()
return expect(smartCliTestObject).be.instanceof(smartcli.Smartcli)
2017-04-22 20:09:51 +00:00
}).catch(tap.threw)
2017-04-22 19:03:28 +00:00
tap.test('should add an command', async () => {
2017-04-22 20:09:51 +00:00
return expect(smartCliTestObject.addCommand('awesome')).to.not.throw
}).catch(tap.threw)
2017-04-22 19:03:28 +00:00
tap.test('should start parsing a standardTask', async () => {
2017-04-22 20:09:51 +00:00
return expect(smartCliTestObject.standardTask()).to.be.instanceOf(Promise)
}).catch(tap.threw)
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
})
2017-04-22 20:09:51 +00:00
return expect(smartCliTestObject.addTrigger('triggerme')).to.be.instanceof(Subject)
}).catch(tap.threw)
2017-04-22 19:03:28 +00:00
tap.test('should not have executed yet', async () => {
2017-04-22 20:09:51 +00:00
return expect(hasExecuted).to.be.false
}).catch(tap.threw)
2017-04-22 19:03:28 +00:00
tap.test('should execute when triggered', async () => {
smartCliTestObject.trigger('triggerme')
2017-04-22 20:09:51 +00:00
return expect(hasExecuted).be.true
}).catch(tap.threw)
2017-04-22 19:03:28 +00:00
/*tap.test('should start parsing the CLI input', async () => {
2017-04-22 19:03:28 +00:00
smartCliTestObject.startParse()
2017-04-22 20:09:51 +00:00
return await expect(smartCliTestObject.parseStarted.promise).to.eventually.be.fulfilled
}).catch(tap.threw)*/