1
0
Fork 0
mirror of https://github.com/betagouv/mon-entreprise synced 2025-02-09 00:35:00 +00:00
mon-entreprise/test/companyStatusSelectors.test.js
Alexandre Hajjar 4f882e3727 Eslint, prettier and tsc fixes
* eslint fixes batch
* fix @typescript-eslint/camelcase (=> warn)
* fix @typescript-eslint/consistent-type-assertions
* fix no-prototype-builtins
* @typescript-eslint/prefer-string-starts-ends-with => warn
* fix @typescript-eslint/prefer-regexp-exec
* fix prefer-const
* fix no-case-declarations
* fix @typescript-eslint/no-var-requires
* fix react/jsx-key
* fix react-hooks/rules-of-hooks
* fix typescript errors following eslint fixes. Includes downgrading:
** @typescript-eslint/no-unnecessary-type-assertion
** @typescript-eslint/no-inferrable-types
* apply prettier
* use `object` type whenever possible
2020-05-05 18:24:14 +02:00

101 lines
2.8 KiB
JavaScript

import { expect } from 'chai'
import { nextQuestionSelector } from 'Selectors/companyStatusSelectors'
const state = companyLegalStatus => ({
inFranceApp: {
companyLegalStatus,
existingCompany: null,
companyStatusChoice: null
}
})
describe('company status selectors', function() {
describe('nextQuestionSelector', function() {
it('should return null there is only one status possible', () => {
const nextQuestion = nextQuestionSelector(
state({
soleProprietorship: true,
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({
soleProprietorship: null,
directorStatus: null,
autoEntrepreneur: null,
multipleAssociates: null,
minorityDirector: null
})
)
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',
soleProprietorship: false
})
)
expect(['directorStatus', 'soleProprietorship']).not.to.contain(
nextQuestion
)
nextQuestion = nextQuestionSelector(
state({
multipleAssociates: true,
soleProprietorship: false
})
)
expect(['multipleAssociates', 'soleProprietorship']).not.to.contain(
nextQuestion
)
})
it('should not return a question which can lead to no matching status', () => {
const nextQuestion = nextQuestionSelector(
state({
multipleAssociates: true,
minorityDirector: true
})
)
expect(nextQuestion).to.be.equal(null)
})
it('should return a question if it can help to shrink down the possibilities', () => {
const nextQuestion = nextQuestionSelector(
state({
soleProprietorship: false,
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('soleProprietorship')
})
it('should allow to skip question', () => {
const nextQuestion = nextQuestionSelector(
state({
multipleAssociates: null
})
)
expect(nextQuestion).not.to.be.equal(null)
})
})
})