smartcli/test/test.ts

52 lines
1.6 KiB
TypeScript
Raw Normal View History

2016-10-14 23:06:36 +00:00
import 'typings-test'
2016-06-10 00:27:04 +00:00
2016-10-14 23:06:36 +00:00
import smartcli = require('../dist/index')
2016-11-19 12:43:06 +00:00
import * as should from 'should'
2015-10-14 18:59:01 +00:00
2016-10-14 23:06:36 +00:00
describe('smartcli.Smartcli class',function(){
2016-10-15 00:12:10 +00:00
let smartCliTestObject: smartcli.Smartcli
2016-10-14 23:06:36 +00:00
describe('new Smartcli()',function(){
it('should create a new Smartcli',function(){
smartCliTestObject = new smartcli.Smartcli()
2016-11-19 12:43:06 +00:00
should(smartCliTestObject).be.instanceof(smartcli.Smartcli)
2016-10-14 23:06:36 +00:00
})
})
describe('.addCommand',function(){
it('should add an command',function(){
2016-12-18 19:53:50 +00:00
smartCliTestObject.addCommand('awesome')
2016-10-14 23:06:36 +00:00
})
})
describe('.standardTask',function(){
it('should start parsing a standardTask',function(done){
2016-06-10 02:13:23 +00:00
smartCliTestObject.standardTask()
.then(() => {
2016-10-14 23:06:36 +00:00
console.log('this is the standard Task!')
})
done()
2016-06-10 02:13:23 +00:00
})
})
2016-12-18 19:53:50 +00:00
describe('.trigger', function() {
2016-12-18 00:36:19 +00:00
let hasExecuted = false
it('should accept a command', function(done) {
2016-12-18 19:53:50 +00:00
smartCliTestObject.addTrigger('triggerme')
.subscribe(() => {
2016-12-18 00:36:19 +00:00
hasExecuted = true
})
done()
})
it('should not have executed yet', function() {
should(hasExecuted).be.false()
})
it('should execute when triggered', function(done) {
2016-12-18 19:53:50 +00:00
smartCliTestObject.trigger('triggerme')
should(hasExecuted).be.true()
done()
2016-12-18 00:36:19 +00:00
})
})
2016-10-14 23:06:36 +00:00
describe('.startParse',function(){
it('should start parsing the CLI input',function(){
smartCliTestObject.startParse()
2016-06-10 02:13:23 +00:00
})
})
2016-10-14 23:06:36 +00:00
})