2018-07-23 13:21:00 +00:00
|
|
|
/* @flow */
|
|
|
|
|
|
|
|
import { expect } from 'chai'
|
|
|
|
import { nextQuestionSelector } from 'Selectors/companyStatusSelectors'
|
|
|
|
const state = companyLegalStatus => ({
|
|
|
|
inFranceApp: {
|
|
|
|
companyLegalStatus,
|
|
|
|
existingCompanyDetails: null,
|
|
|
|
}
|
|
|
|
})
|
|
|
|
describe('company status selectors', function() {
|
|
|
|
describe('nextQuestionSelector', function() {
|
|
|
|
it('should return null there is only one status possible', () => {
|
|
|
|
const nextQuestion = nextQuestionSelector(
|
|
|
|
state({
|
2018-09-13 12:49:34 +00:00
|
|
|
liability: 'UNLIMITED_LIABILITY',
|
2018-07-23 13:21:00 +00:00
|
|
|
directorStatus: 'SELF_EMPLOYED',
|
|
|
|
multipleAssociates: true
|
|
|
|
})
|
|
|
|
)
|
|
|
|
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({
|
|
|
|
liability: null,
|
|
|
|
directorStatus: null,
|
2018-09-19 13:31:53 +00:00
|
|
|
microEnterprise: null,
|
2018-08-02 10:20:53 +00:00
|
|
|
multipleAssociates: null,
|
|
|
|
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',
|
|
|
|
liability: 'LIMITED_LIABILITY'
|
|
|
|
})
|
|
|
|
)
|
|
|
|
expect(['directorStatus', 'liability']).not.to.contain(nextQuestion)
|
|
|
|
|
|
|
|
nextQuestion = nextQuestionSelector(
|
|
|
|
state({
|
|
|
|
multipleAssociates: true,
|
|
|
|
liability: 'LIMITED_LIABILITY'
|
|
|
|
})
|
|
|
|
)
|
|
|
|
expect(['multipleAssociates', 'liability']).not.to.contain(nextQuestion)
|
|
|
|
})
|
|
|
|
it('should not return a question which can lead to no matching status', () => {
|
|
|
|
const nextQuestion = nextQuestionSelector(
|
|
|
|
state({
|
2018-09-13 12:49:34 +00:00
|
|
|
liability: 'UNLIMITED_LIABILITY',
|
2018-07-23 13:21:00 +00:00
|
|
|
multipleAssociates: null,
|
2018-09-19 13:31:53 +00:00
|
|
|
microEnterprise: null,
|
2018-08-02 10:20:53 +00:00
|
|
|
minorityDirector: null,
|
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({
|
|
|
|
liability: 'LIMITED_LIABILITY',
|
|
|
|
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({}))
|
|
|
|
expect(nextQuestion).to.be.equal('multipleAssociates')
|
|
|
|
})
|
2018-08-02 10:20:53 +00:00
|
|
|
|
|
|
|
it('should interpret missing question in status as not relevant', () => {
|
|
|
|
const nextQuestion = nextQuestionSelector(
|
|
|
|
state({
|
|
|
|
minorityDirector: true
|
|
|
|
})
|
|
|
|
)
|
|
|
|
expect(nextQuestion).not.to.be.equal(null)
|
|
|
|
})
|
|
|
|
|
|
|
|
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
|
|
|
})
|
|
|
|
})
|