smartcli/test/test.ts

45 lines
1.1 KiB
TypeScript
Raw Normal View History

2017-04-22 19:03:28 +00:00
import { tap, expect } from 'tapbundle'
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)
})
tap.test('should add an command', async () => {
smartCliTestObject.addCommand('awesome')
})
tap.test('should start parsing a standardTask', async () => {
smartCliTestObject.standardTask()
.then(() => {
console.log('this is the standard Task!')
2016-12-18 00:36:19 +00:00
})
2017-04-22 19:03:28 +00:00
})
let hasExecuted: boolean = false
tap.test('should accept a command', async () => {
smartCliTestObject.addTrigger('triggerme')
.subscribe(() => {
hasExecuted = true
2016-06-10 02:13:23 +00:00
})
2016-10-14 23:06:36 +00:00
})
2017-04-22 19:03:28 +00:00
tap.test('should not have executed yet', async () => {
expect(hasExecuted).to.be.false
})
tap.test('should execute when triggered', async () => {
smartCliTestObject.trigger('triggerme')
expect(hasExecuted).be.true
})
tap.test('should start parsing the CLI input', async () => {
smartCliTestObject.startParse()
})