smartinteract/test/test.ts

55 lines
1.5 KiB
TypeScript
Raw Normal View History

import { expect, tap } from '@pushrocks/tapbundle';
2016-11-20 00:11:22 +00:00
import * as smartinteract from '../ts/index';
2016-11-20 00:11:22 +00:00
let testInteract: smartinteract.SmartInteract;
tap.test('should create a valid new instance', async () => {
testInteract = new smartinteract.SmartInteract();
expect(testInteract).to.be.instanceOf(smartinteract.SmartInteract);
});
2020-08-31 19:23:51 +00:00
tap.test('should get a simple confirmation', async () => {
2020-08-31 19:25:25 +00:00
const response = await smartinteract.SmartInteract.getCliConfirmation(
'You feel awesome, right?',
true
);
2020-08-31 19:23:51 +00:00
expect(response).to.be.true;
});
tap.test('should add question to SmartInteract instance', async () => {
testInteract.addQuestions([
{
name: 'testQuestion1',
type: 'input',
message: 'what is your favourite color? Answer is blue',
2020-08-31 19:23:51 +00:00
default: 'blue',
},
]);
testInteract.addQuestions([
{
name: 'testQuestion2',
type: 'input',
message: 'what is your second favourite color? Answer is red',
2020-08-31 19:23:51 +00:00
default: 'red',
},
]);
testInteract.addQuestions([
{
name: 'some.dotted.name',
type: 'input',
2020-02-02 13:45:59 +00:00
message: 'what is your second favourite color? Answer is aValidAnswer',
2020-08-31 19:23:51 +00:00
default: 'aValidAnswer',
},
]);
});
tap.test('should use default value when not in CI', async () => {
2020-02-02 13:45:59 +00:00
const answerBucket = await testInteract.runQueue();
expect(answerBucket.getAnswerFor('testQuestion1')).to.equal('blue');
expect(answerBucket.getAnswerFor('testQuestion2')).to.equal('red');
expect(answerBucket.getAnswerFor('some.dotted.name')).to.equal('aValidAnswer');
});
tap.start();