implement AnswerBucket

This commit is contained in:
2016-11-20 22:24:09 +01:00
parent 638282d91c
commit 4a81f148b4
6 changed files with 237 additions and 47 deletions

View File

@@ -4,13 +4,34 @@ import * as should from 'should'
import * as smartinteract from '../dist/index'
describe('smartinteract', function(){
let testInteract
let testInteract: smartinteract.SmartInteract
it('should create a valid new instance', function(){
testInteract = new smartinteract.SmartInteract()
should(testInteract).be.instanceOf(smartinteract.SmartInteract)
})
it('should add question to SmartInteract instance', function() {
testInteract.addQuestions([{
name: 'testQuestion1',
type: 'input',
message: 'what is your favourite color? Answer is blue',
default: 'blue'
}])
testInteract.addQuestions([{
name: 'testQuestion2',
type: 'input',
message: 'what is your second favourite color? Answer is red',
default: 'red'
}])
})
it('should use default value when not in CI', function(done){
this.timeout(30000)
testInteract.runQueue().then(answerBucket => {
should(answerBucket.getAnswerFor('testQuestion1')).equal('blue')
should(answerBucket.getAnswerFor('testQuestion2')).equal('red')
done()
}).catch(err => {
console.log(err)
throw err
})
})
})