update tests

This commit is contained in:
2017-04-22 22:09:51 +02:00
parent 3ff4c3ff2f
commit 5e66d35125
6 changed files with 28 additions and 30 deletions

View File

@ -1,4 +1,5 @@
import { tap, expect } from 'tapbundle'
import { Subject } from 'rxjs'
import smartcli = require('../dist/index')
@ -7,20 +8,16 @@ 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)
tap.test('should add an command', async () => {
smartCliTestObject.addCommand('awesome')
})
return expect(smartCliTestObject.addCommand('awesome')).to.not.throw
}).catch(tap.threw)
tap.test('should start parsing a standardTask', async () => {
smartCliTestObject.standardTask()
.then(() => {
console.log('this is the standard Task!')
})
})
return expect(smartCliTestObject.standardTask()).to.be.instanceOf(Promise)
}).catch(tap.threw)
let hasExecuted: boolean = false
tap.test('should accept a command', async () => {
@ -28,17 +25,20 @@ tap.test('should accept a command', async () => {
.subscribe(() => {
hasExecuted = true
})
})
return expect(smartCliTestObject.addTrigger('triggerme')).to.be.instanceof(Subject)
}).catch(tap.threw)
tap.test('should not have executed yet', async () => {
expect(hasExecuted).to.be.false
})
return expect(hasExecuted).to.be.false
}).catch(tap.threw)
tap.test('should execute when triggered', async () => {
smartCliTestObject.trigger('triggerme')
expect(hasExecuted).be.true
})
return expect(hasExecuted).be.true
}).catch(tap.threw)
tap.test('should start parsing the CLI input', async () => {
smartCliTestObject.startParse()
})
return await expect(smartCliTestObject.parseStarted.promise).to.eventually.be.fulfilled
}).catch(tap.threw)