2016-11-20 00:11:22 +00:00
|
|
|
import 'typings-test'
|
|
|
|
import * as should from 'should'
|
|
|
|
|
|
|
|
import * as smartinteract from '../dist/index'
|
|
|
|
|
|
|
|
describe('smartinteract', function(){
|
2016-11-20 21:24:09 +00:00
|
|
|
let testInteract: smartinteract.SmartInteract
|
2016-11-20 00:11:22 +00:00
|
|
|
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() {
|
2016-11-20 21:24:09 +00:00
|
|
|
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
|
|
|
|
})
|
2016-11-20 00:11:22 +00:00
|
|
|
})
|
|
|
|
})
|