2021-12-27 15:03:49 +00:00
import { describe , it , expect } from 'vitest'
2020-12-09 11:41:58 +00:00
import rules from 'modele-social'
2021-11-30 16:47:28 +00:00
import { utils } from 'publicodes'
2020-10-08 09:29:07 +00:00
describe ( 'DottedNames graph' , ( ) => {
it ( "shouldn't have cycles" , ( ) => {
2021-11-30 16:47:28 +00:00
const [ cyclesDependencies , dotGraphs ] = utils . cyclicDependencies ( rules )
2021-05-04 17:40:10 +00:00
const dotGraphsToLog = dotGraphs
. map (
( dotGraph ) =>
` 🌀🌀🌀🌀🌀🌀🌀🌀🌀🌀🌀 \n A cycle graph to stare at with Graphviz: \n ${ dotGraph } \n \n `
)
. join ( '\n\n' )
2020-10-08 09:29:07 +00:00
expect (
2020-11-24 16:22:34 +00:00
cyclesDependencies ,
2021-05-04 17:40:10 +00:00
` ${ dotGraphsToLog } \n AT LEAST the following cycles have been found in the rules dependencies graph. \n See below for a representation of each cycle. \n ⬇️ is a node of the cycle. \n \t - ${ cyclesDependencies
2020-10-08 09:29:07 +00:00
. map (
( cycleDependencies , idx ) =>
2021-05-04 17:40:10 +00:00
'#' + idx + ':\n\t\t⬇️ ' + cycleDependencies . join ( '\n\t\t⬇️ ' )
2020-10-08 09:29:07 +00:00
)
. join ( '\n\t- ' ) } \ n \ n `
2021-05-04 17:40:10 +00:00
) . to . deep . equal ( [
[
2021-07-28 11:42:44 +00:00
'dirigeant . rémunération . imposable' ,
'dirigeant . auto-entrepreneur . impôt . revenu imposable' ,
2021-05-04 17:40:10 +00:00
"entreprise . chiffre d'affaires" ,
2021-06-30 08:20:42 +00:00
'dirigeant . rémunération . nette après impôt' ,
'dirigeant . rémunération . nette' ,
'dirigeant . rémunération . totale' ,
2021-09-14 10:46:48 +00:00
'impôt . montant' ,
2021-06-30 08:20:42 +00:00
'impôt . revenu imposable' ,
2021-05-04 17:40:10 +00:00
] ,
] )
console . warn (
"[ WARNING ] A cycle still exists around `entreprise . chiffre d'affaires` see issue #1524 for a definitive fix."
2020-12-01 09:17:27 +00:00
)
2020-10-08 09:29:07 +00:00
} )
} )