1
0
Fork 0
mirror of https://github.com/betagouv/mon-entreprise synced 2025-02-09 05:15:02 +00:00
mon-entreprise/mon-entreprise/test/cycles.test.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
1.3 KiB
JavaScript
Raw Normal View History

import { expect } from 'chai'
import rules from 'modele-social'
import { cyclicDependencies } from '../../publicodes/core/source/AST/graph'
describe('DottedNames graph', () => {
it("shouldn't have cycles", () => {
const [cyclesDependencies, dotGraphs] = cyclicDependencies(rules)
const dotGraphsToLog = dotGraphs
.map(
(dotGraph) =>
`🌀🌀🌀🌀🌀🌀🌀🌀🌀🌀🌀\n A cycle graph to stare at with Graphviz:\n${dotGraph}\n\n`
)
.join('\n\n')
expect(
cyclesDependencies,
`${dotGraphsToLog}\nAT LEAST the following cycles have been found in the rules dependencies graph.\nSee below for a representation of each cycle.\n⬇️ is a node of the cycle.\n\t- ${cyclesDependencies
.map(
(cycleDependencies, idx) =>
'#' + idx + ':\n\t\t⬇ ' + cycleDependencies.join('\n\t\t⬇ ')
)
.join('\n\t- ')}\n\n`
).to.deep.equal([
[
"entreprise . chiffre d'affaires",
'dirigeant . rémunération . impôt',
'dirigeant . rémunération . imposable',
'dirigeant . auto-entrepreneur . impôt . revenu imposable',
"entreprise . chiffre d'affaires . vente restauration hébergement",
],
])
console.warn(
"[ WARNING ] A cycle still exists around `entreprise . chiffre d'affaires` see issue #1524 for a definitive fix."
)
})
})