Files
cypress/scripts/unit/binary/util/questions-remain-spec.js
T
Jennifer Shehane ea83415637 chore: move questions-remain into cypress repo (#29542)
* chore: move questions-remain into cypress repo

* to js file

* SLASH!
2024-06-03 10:42:55 -04:00

47 lines
1.2 KiB
JavaScript

/* global sinon */
const questionsRemain = require('../../../binary/util/questions-remain')
const la = require('lazy-ass')
const snapshot = require('snap-shot-it')
describe('questions-remain', () => {
const dontAsk = () => {
throw new Error('Should not ask!')
}
it('is a function', () => {
if (typeof questionsRemain !== 'function') throw new Error('questionsRemain is not a function')
})
it('returns object if all questions have been answered', () => {
const propertiesToQuestions = {
foo: dontAsk,
bar: dontAsk,
}
const options = {
foo: 'foo is specified',
bar: 'so is bar',
}
// console.log(questionsRemain(propertiesToQuestions)(options))
return questionsRemain(propertiesToQuestions)(options).then(snapshot)
})
it('asks questions for missing options', () => {
const barStub = sinon.stub().resolves('bar user answer')
const propertiesToQuestions = {
foo: dontAsk,
bar: barStub,
}
const options = {
foo: 'foo is specified',
// notice bar is missing!
}
return questionsRemain(propertiesToQuestions)(options)
.then(snapshot)
.then(() => {
la(barStub.called, 'bar stub has not been called')
})
})
})