2018-07-23 13:21:00 +00:00
|
|
|
|
|
|
|
import { expect } from 'chai'
|
|
|
|
import { nextQuestionSelector } from 'Selectors/companyStatusSelectors'
|
|
|
|
const state = companyLegalStatus => ({
|
|
|
|
inFranceApp: {
|
|
|
|
companyLegalStatus,
|
2019-09-26 17:12:35 +00:00
|
|
|
existingCompany: null,
|
2019-02-15 17:45:46 +00:00
|
|
|
companyStatusChoice: null
|
2018-07-23 13:21:00 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
describe('company status selectors', function() {
|
|
|
|
describe('nextQuestionSelector', function() {
|
|
|
|
it('should return null there is only one status possible', () => {
|
|
|
|
const nextQuestion = nextQuestionSelector(
|
|
|
|
state({
|
2019-02-15 17:45:46 +00:00
|
|
|
soleProprietorship: true,
|
2018-07-23 13:21:00 +00:00
|
|
|
directorStatus: 'SELF_EMPLOYED',
|
2019-02-15 17:45:46 +00:00
|
|
|
multipleAssociates: true
|
2018-07-23 13:21:00 +00:00
|
|
|
})
|
|
|
|
)
|
|
|
|
expect(nextQuestion).to.be.equal(null)
|
|
|
|
})
|
|
|
|
it('should not return null if no questions have been answered yet', () => {
|
|
|
|
const nextQuestion = nextQuestionSelector(state({}))
|
|
|
|
expect(nextQuestion).not.to.be.equal(null)
|
|
|
|
})
|
|
|
|
it('should return null if all the questions have been answered', () => {
|
|
|
|
const nextQuestion = nextQuestionSelector(
|
|
|
|
state({
|
2019-02-15 17:45:46 +00:00
|
|
|
soleProprietorship: null,
|
2018-07-23 13:21:00 +00:00
|
|
|
directorStatus: null,
|
2019-01-30 17:38:17 +00:00
|
|
|
autoEntrepreneur: null,
|
2018-08-02 10:20:53 +00:00
|
|
|
multipleAssociates: null,
|
2019-02-15 17:45:46 +00:00
|
|
|
minorityDirector: null
|
2018-07-23 13:21:00 +00:00
|
|
|
})
|
|
|
|
)
|
|
|
|
expect(nextQuestion).to.be.equal(null)
|
|
|
|
})
|
|
|
|
it('should always return a question that have not been answered yet', () => {
|
|
|
|
let nextQuestion = nextQuestionSelector(
|
|
|
|
state({
|
|
|
|
directorStatus: null,
|
|
|
|
multipleAssociates: null
|
|
|
|
})
|
|
|
|
)
|
|
|
|
expect(['directorStatus', 'multipleAssociates']).not.to.contain(
|
|
|
|
nextQuestion
|
|
|
|
)
|
|
|
|
|
|
|
|
nextQuestion = nextQuestionSelector(
|
|
|
|
state({
|
|
|
|
directorStatus: 'SALARIED',
|
2019-02-15 17:45:46 +00:00
|
|
|
soleProprietorship: false
|
2018-07-23 13:21:00 +00:00
|
|
|
})
|
|
|
|
)
|
2019-02-15 17:45:46 +00:00
|
|
|
expect(['directorStatus', 'soleProprietorship']).not.to.contain(
|
|
|
|
nextQuestion
|
|
|
|
)
|
2018-07-23 13:21:00 +00:00
|
|
|
|
|
|
|
nextQuestion = nextQuestionSelector(
|
|
|
|
state({
|
|
|
|
multipleAssociates: true,
|
2019-02-15 17:45:46 +00:00
|
|
|
soleProprietorship: false
|
2018-07-23 13:21:00 +00:00
|
|
|
})
|
|
|
|
)
|
2019-02-15 17:45:46 +00:00
|
|
|
expect(['multipleAssociates', 'soleProprietorship']).not.to.contain(
|
|
|
|
nextQuestion
|
|
|
|
)
|
2018-07-23 13:21:00 +00:00
|
|
|
})
|
|
|
|
it('should not return a question which can lead to no matching status', () => {
|
|
|
|
const nextQuestion = nextQuestionSelector(
|
|
|
|
state({
|
2019-02-15 17:45:46 +00:00
|
|
|
multipleAssociates: true,
|
|
|
|
minorityDirector: true
|
2018-07-23 13:21:00 +00:00
|
|
|
})
|
|
|
|
)
|
|
|
|
expect(nextQuestion).to.be.equal(null)
|
|
|
|
})
|
|
|
|
it('should return a question if it can help to shrink down the possibilities', () => {
|
|
|
|
const nextQuestion = nextQuestionSelector(
|
|
|
|
state({
|
2019-02-15 17:45:46 +00:00
|
|
|
soleProprietorship: false,
|
2018-07-23 13:21:00 +00:00
|
|
|
directorStatus: 'SALARIED'
|
|
|
|
})
|
|
|
|
)
|
|
|
|
expect(nextQuestion).not.to.be.equal(null)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should first return the question which convey the most information (which eliminates the most statuses ) ', () => {
|
|
|
|
const nextQuestion = nextQuestionSelector(state({}))
|
2019-02-15 17:45:46 +00:00
|
|
|
expect(nextQuestion).to.be.equal('soleProprietorship')
|
2018-07-23 13:21:00 +00:00
|
|
|
})
|
2018-08-02 10:20:53 +00:00
|
|
|
it('should allow to skip question', () => {
|
|
|
|
const nextQuestion = nextQuestionSelector(
|
|
|
|
state({
|
|
|
|
multipleAssociates: null
|
|
|
|
})
|
|
|
|
)
|
|
|
|
expect(nextQuestion).not.to.be.equal(null)
|
|
|
|
})
|
2018-07-23 13:21:00 +00:00
|
|
|
})
|
|
|
|
})
|