-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b218b40
commit a96f853
Showing
26 changed files
with
22,224 additions
and
746 deletions.
There are no files selected for viewing
22,151 changes: 21,717 additions & 434 deletions
22,151
api/source/test-e2e/__snapshots__/index.test.ts.snap
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import rules, { DottedName } from 'modele-social' | ||
import Engine from 'publicodes' | ||
import { beforeEach, describe, expect, it } from 'vitest' | ||
|
||
import { Situation } from '@/domaine/Situation' | ||
|
||
describe('Un artiste-auteur', () => { | ||
let engine: Engine<DottedName> | ||
beforeEach(() => { | ||
engine = new Engine(rules) | ||
}) | ||
|
||
const situation: Situation = { | ||
'artiste-auteur': 'oui', | ||
salarié: 'oui', | ||
} | ||
|
||
describe('salarié à 1000 €/an', () => { | ||
const situationSalarié = { | ||
...situation, | ||
salarié: 'oui', | ||
'artiste-auteur . revenus . traitements et salaires': '1000 €/an', | ||
} | ||
|
||
it('paie des cotisations', () => { | ||
const e = engine.setSituation(situationSalarié) | ||
|
||
expect(e).toEvaluate('artiste-auteur . cotisations', 160) | ||
}) | ||
|
||
it('ne paie pas d’IRCEC', () => { | ||
const e = engine.setSituation(situationSalarié) | ||
|
||
expect(e).toEvaluate('artiste-auteur . cotisations . IRCEC', 0) | ||
}) | ||
}) | ||
|
||
describe('avec un revenu BNC de 10 000 €/an', () => { | ||
const situationBNC = { | ||
...situation, | ||
'artiste-auteur . revenus . BNC . recettes': '10000 €/an', | ||
} | ||
|
||
it('paie des cotisations', () => { | ||
const e = engine.setSituation(situationBNC) | ||
|
||
expect(e).toEvaluate('artiste-auteur . cotisations', 1230) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import rules, { DottedName } from 'modele-social' | ||
import Engine from 'publicodes' | ||
import { beforeEach, describe, expect, it } from 'vitest' | ||
|
||
describe('Auto-entrepreneur', function () { | ||
let engine: Engine<DottedName> | ||
beforeEach(() => { | ||
engine = new Engine(rules) | ||
}) | ||
it('Un auto-entrepreneur a le régime social auto-entrepreneur', function () { | ||
const situation = engine.setSituation({ | ||
'entreprise . catégorie juridique': "'EI'", | ||
'entreprise . catégorie juridique . EI . auto-entrepreneur': 'oui', | ||
}) | ||
|
||
expect(situation).toEvaluate( | ||
'dirigeant . régime social', | ||
'auto-entrepreneur' | ||
) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import rules, { DottedName } from 'modele-social' | ||
import Engine from 'publicodes' | ||
import { beforeEach, describe, expect, it } from 'vitest' | ||
|
||
describe('Un avocat', () => { | ||
let engine: Engine<DottedName> | ||
beforeEach(() => { | ||
engine = new Engine(rules) | ||
}) | ||
|
||
const chiffreDAffaires = 6264 | ||
|
||
const situation = { | ||
'dirigeant . indépendant . cotisations facultatives': 'oui', | ||
'entreprise . activité . nature . libérale . réglementée': 'oui', | ||
'dirigeant . indépendant . PL . métier': "'avocat'", | ||
'entreprise . activité . nature': "'libérale'", | ||
'entreprise . date de création': '01/01/2021', | ||
"entreprise . chiffre d'affaires": `${chiffreDAffaires} €/an`, | ||
'entreprise . catégorie juridique': "'EI'", | ||
'entreprise . catégorie juridique . EI . auto-entrepreneur': 'non', | ||
} | ||
|
||
it('est un indépendant', () => { | ||
const e = engine.setSituation(situation) | ||
expect(e).toEvaluate('entreprise . catégorie juridique', 'EI') | ||
expect(e).toEvaluate('dirigeant . régime social', 'indépendant') | ||
}) | ||
|
||
it('paie des cotisations inférieures à son chiffre d’affaires', () => { | ||
const e = engine.setSituation(situation) | ||
|
||
const cotisations = e.evaluate( | ||
'dirigeant . rémunération . cotisations' | ||
).nodeValue | ||
|
||
expect(cotisations).toSatisfy((c: number) => c > 0 && c < chiffreDAffaires) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export type PublicodesTypes = | ||
| number | ||
| boolean | ||
| string | ||
| Record<string, unknown> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { DottedName } from 'modele-social' | ||
import Engine from 'publicodes' | ||
|
||
export const logValue = (e: Engine, rule: DottedName) => { | ||
// eslint-disable-next-line no-console | ||
console.log(`${rule} =`, e.evaluate(rule).nodeValue) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* eslint-disable @typescript-eslint/no-unsafe-call */ | ||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ | ||
import { DottedName } from 'modele-social' | ||
import Engine, { Evaluation } from 'publicodes' | ||
import { expect } from 'vitest' | ||
|
||
import { PublicodesTypes } from '../helpers/PublicodesTypes' | ||
|
||
const toEvaluate = function <T extends PublicodesTypes>( | ||
engine: Engine, | ||
rule: DottedName, | ||
value: Evaluation<T> | ||
) { | ||
const evaluated = engine.evaluate(rule).nodeValue | ||
const pass = evaluated === value | ||
|
||
if (pass) { | ||
return { | ||
message: () => | ||
// `this` context will have correct typings | ||
// @ts-ignore | ||
`expected ${this.utils.printReceived( | ||
evaluated | ||
// @ts-ignore | ||
)} not to equal ${this.utils.printExpected( | ||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions | ||
`${value}` | ||
)} for rule ${rule}`, | ||
pass: true, | ||
} | ||
} else { | ||
return { | ||
message: () => | ||
// @ts-ignore | ||
`expected ${this.utils.printReceived( | ||
evaluated | ||
// @ts-ignore | ||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions | ||
)} to equal ${this.utils.printExpected(`${value}`)} for rule ${rule}`, | ||
pass: false, | ||
} | ||
} | ||
} | ||
|
||
expect.extend({ | ||
toEvaluate, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.