mirror of
https://github.com/betagouv/mon-entreprise
synced 2025-02-09 01:45:03 +00:00
Cela permet l'inférence de type à partir des fichiers js qui ne sont pas encore convertis en TypeScript. Par ailleurs suppression des dernières traces de Flow. Ajout d'options plus strictes pour dans la config tsconfig.js
70 lines
2.1 KiB
JavaScript
70 lines
2.1 KiB
JavaScript
import { expect } from 'chai'
|
|
import salariéConfig from 'Components/simulationConfigs/salarié.yaml'
|
|
import { getRuleFromAnalysis, rules } from 'Engine/rules'
|
|
import { analysisWithDefaultsSelector } from 'Selectors/analyseSelectors'
|
|
import {
|
|
analysisToCotisationsSelector,
|
|
COTISATION_BRANCHE_ORDER
|
|
} from 'Selectors/ficheDePaieSelectors'
|
|
|
|
let state = {
|
|
rules,
|
|
simulation: {
|
|
config: salariéConfig,
|
|
situation: {
|
|
'contrat salarié . rémunération . brut de base': '2300',
|
|
'entreprise . effectif': '50'
|
|
}
|
|
},
|
|
conversationSteps: {
|
|
foldedSteps: []
|
|
}
|
|
}
|
|
|
|
let cotisations = null,
|
|
analysis
|
|
|
|
describe('pay slip selector', function() {
|
|
beforeEach(() => {
|
|
cotisations = analysisToCotisationsSelector(state)
|
|
analysis = analysisWithDefaultsSelector(state)
|
|
|
|
expect(cotisations).not.to.eq(null)
|
|
})
|
|
it('should have cotisations grouped by branches in the proper ordering', function() {
|
|
let branches = cotisations.map(([branche]) => branche)
|
|
expect(branches).to.eql(COTISATION_BRANCHE_ORDER)
|
|
})
|
|
|
|
it('should collect all cotisations in a branche', function() {
|
|
let cotisationsSanté = (cotisations.find(([branche]) =>
|
|
branche.includes('santé')
|
|
) || [])[1].map(cotisation => cotisation.name)
|
|
expect(cotisationsSanté).to.have.lengthOf(2)
|
|
expect(cotisationsSanté).to.include('maladie')
|
|
expect(cotisationsSanté).to.include('complémentaire santé')
|
|
})
|
|
|
|
it('should sum all cotisations', function() {
|
|
let pat = getRuleFromAnalysis(analysis)(
|
|
'contrat salarié . cotisations . patronales'
|
|
),
|
|
sal = getRuleFromAnalysis(analysis)(
|
|
'contrat salarié . cotisations . salariales'
|
|
)
|
|
expect(pat.nodeValue).to.be.closeTo(824.7, 5)
|
|
expect(sal.nodeValue).to.be.closeTo(498, 5)
|
|
})
|
|
|
|
it('should have value for "salarié" and "employeur" for a cotisation', function() {
|
|
let cotisationATMP = (cotisations.find(([branche]) =>
|
|
branche.includes('accidents du travail et maladies professionnelles')
|
|
) || [])[1][0]
|
|
expect(cotisationATMP.montant.partSalariale).to.be.closeTo(0, 0.1)
|
|
let defaultATMPRate = 2.22 / 100
|
|
expect(cotisationATMP.montant.partPatronale).to.be.closeTo(
|
|
2300 * defaultATMPRate,
|
|
1
|
|
)
|
|
})
|
|
})
|