chore: fix lint error

pull/2901/head
Johan Girod 2024-02-23 11:31:44 +01:00
parent d5607fe8f1
commit 9f8633f7cd
10 changed files with 44 additions and 34 deletions

View File

@ -159,6 +159,15 @@ module.exports = {
'prettier',
],
plugins: ['@typescript-eslint', 'vitest', 'testing-library'],
rules: {
'vitest/expect-expect': [
'error',
{
assertFunctionNames: ['expect', 'runSimulations'],
additionalTestBlockFunctions: [],
},
],
},
},
// Accessibility rules on /site
{

View File

@ -3,7 +3,8 @@
## 2.0.1
- [protection sociale] Ajoute une condition de revenu pour bénéficier de la pension d'invalité pour les salariés
- publicodes : update to 1.0.2 (fix a bug with non applicable & contexte)
- Répare le calcul des cotisations forfaitaires de début d'activité
- publicodes : update to 1.0.4
## 2.0.0

View File

@ -1,4 +1,4 @@
import { checkA11Y, fr } from '../../support/utils'
import { fr } from '../../support/utils'
describe('Simulateur indépendant', { testIsolation: false }, function () {
if (!fr) {
@ -18,8 +18,4 @@ describe('Simulateur indépendant', { testIsolation: false }, function () {
)
cy.contains('Montant des cotisations forfaitaires').should('not.exist')
})
it('should be RGAA compliant', function () {
checkA11Y()
})
})

View File

@ -7,7 +7,14 @@ type ViolationType = {
export const checkA11Y = () => {
cy.injectAxe()
cy.configureAxe({})
cy.configureAxe({
rules: [
{
id: 'color-contrast',
enabled: false,
},
],
})
cy.checkA11y(
null,
null,

View File

@ -13,7 +13,7 @@ describe('conversation', function () {
'top . a': { question: '?', titre: 'a', unité: '€' },
'top . b': { question: '?', titre: 'b', unité: '€' },
}).evaluate('top . startHere').missingVariables
expect(getNextQuestions(missingVariables)[0]).to.equal('top . a')
expect(getNextQuestions(missingVariables)[0]).toBe('top . a')
})
it('should first ask for questions without defaults, then those with defaults', function () {
const engine = new Engine({
@ -45,17 +45,17 @@ describe('conversation', function () {
},
})
expect(
getNextQuestions(engine.evaluate('net').missingVariables)[0]
).to.equal('brut')
expect(getNextQuestions(engine.evaluate('net').missingVariables)[0]).toBe(
'brut'
)
engine.setSituation({
brut: 2300,
})
expect(
getNextQuestions(engine.evaluate('net').missingVariables)[0]
).to.equal('cadre')
expect(getNextQuestions(engine.evaluate('net').missingVariables)[0]).toBe(
'cadre'
)
})
it('should ask "motif CDD" if "CDD" applies', function () {
@ -70,6 +70,6 @@ describe('conversation', function () {
.missingVariables
)
expect(result).to.include('salarié . contrat . CDD . motif')
expect(result).toContain('salarié . contrat . CDD . motif')
})
})

View File

@ -11,11 +11,11 @@ describe('Fabrique Social', () => {
describe('getSiegeOrFirstEtablissement Function', () => {
it('should return siege', () => {
const siege = getSiegeOrFirstEtablissement(fabriqueSocialWithSiege)
expect(siege.address).to.equal('23 RUE DE MOGADOR 75009 PARIS 9')
expect(siege.address).toBe('23 RUE DE MOGADOR 75009 PARIS 9')
})
it('should return FirstEtablissement', () => {
const siege = getSiegeOrFirstEtablissement(fabriqueSocialWithoutSiege)
expect(siege.address).to.equal('4 RUE VOLTAIRE 44000 NANTES')
expect(siege.address).toBe('4 RUE VOLTAIRE 44000 NANTES')
})
})
})

View File

@ -7,7 +7,7 @@ describe('modele-social', function () {
beforeAll(() => {
engine = new Engine(rules)
})
it("ne change pas le montant de l'IR ni des cotisations lorsqu'on verse un forfait mobilités durables ", function () {
it("ne change pas le montant de l'IR ni des cotisations lorsqu'on verse un forfait mobilités durables", function () {
expect(
engine
.setSituation({ 'salarié . contrat . salaire brut': 2300 })

View File

@ -56,13 +56,13 @@ describe('[persistence] When simulation persistence is setup', () => {
})
it('saves state in localStorage with all fields', () => {
expect(setItemSpy).toHaveBeenCalled()
expect(setItemSpy.mock.calls[0]![1]).to.equal(
expect(setItemSpy.mock.calls[0]![1]).toBe(
'{"situation":{"dotted name":"42"},"activeTargetInput":"sometargetinput","foldedSteps":["somestep"]}'
)
})
it('saves state in localStorage with a key dependent on the simulation url', () => {
expect(setItemSpy).toHaveBeenCalled()
expect(setItemSpy.mock.calls[0]![0]).to.contain('someurl')
expect(setItemSpy.mock.calls[0]![0]).toContain('someurl')
})
})
})
@ -91,20 +91,18 @@ describe('[persistence] When simulation config is set', () => {
store.dispatch(loadPreviousSimulation())
})
it('loads url in state', () => {
expect(store.getState().simulation.url).to.eq('/someotherurl')
expect(store.getState().simulation.url).toBe('/someotherurl')
})
it('loads situation in state', () => {
expect(store.getState().simulation.situation).to.deep.eq({
expect(store.getState().simulation.situation).toEqual({
'dotted name . other': '42',
})
})
it('loads activeTargetInput in state', () => {
expect(store.getState().activeTargetInput).to.eq('someothertargetinput')
expect(store.getState().activeTargetInput).toBe('someothertargetinput')
})
it('loads foldedSteps in state', () => {
expect(store.getState().simulation.foldedSteps).to.deep.eq([
'someotherstep',
])
expect(store.getState().simulation.foldedSteps).toEqual(['someotherstep'])
})
})
})

View File

@ -25,6 +25,6 @@ describe('Tests units', function () {
const missingTranslations = units.filter(
(unit) => ![...translatedKeys, ...blackList].includes(unit)
)
expect(missingTranslations).to.be.empty
expect(missingTranslations).toHaveLength(0)
})
})

View File

@ -19,8 +19,7 @@ describe('identifiant court', () => {
])
it('should be unique amongst rules', () => {
expect(questions.length).to.greaterThan(0)
expect(questions.length).to.eq(
expect(questions).toHaveLength(
new Set(questions.map(([, name]) => name)).size
)
})
@ -47,7 +46,7 @@ rule without:
dottedNameParamName,
'€/an'
).toString()
).to.equal(
).toBe(
new URLSearchParams(
'panta=2000€/mois&rule without=1000€/mois&unite=€/an'
).toString()
@ -61,7 +60,7 @@ rule without:
dottedNameParamName,
'€/an'
).toString()
).to.equal(
).toBe(
new URLSearchParams('rule without={"1":2,"3":{"4":"5"}}').toString() +
'&unite=%E2%82%AC%2Fan'
)
@ -69,7 +68,7 @@ rule without:
it('handles empty situation with proper defaults', () => {
expect(
getSearchParams(engine, {}, dottedNameParamName, '€/mois').toString()
).to.equal('unite=%E2%82%AC%2Fmois')
).toBe('unite=%E2%82%AC%2Fmois')
})
})
@ -80,7 +79,7 @@ rule without:
new URLSearchParams('panta=2000€/mois&rule without=1000€/mois'),
dottedNameParamName
)
).to.deep.equal({
).toEqual({
'rule with': '2000€/mois',
'rule without': '1000€/mois',
})
@ -91,7 +90,7 @@ rule without:
new URLSearchParams(''),
dottedNameParamName
)
).to.deep.equal({})
).toEqual({})
})
})
})