2020-10-08 11:29:07 +02:00
import { expect } from 'chai'
2020-12-09 12:41:58 +01:00
import rules from 'modele-social'
2021-01-26 16:30:44 +01:00
import { cyclicDependencies } from '../../publicodes/core/source/AST/graph'
2020-10-08 11:29:07 +02:00
describe ( 'DottedNames graph' , ( ) => {
it ( "shouldn't have cycles" , ( ) => {
2021-05-04 19:40:10 +02:00
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' )
2020-10-08 11:29:07 +02:00
expect (
2020-11-24 17:22:34 +01:00
cyclesDependencies ,
2021-05-04 19:40:10 +02: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 11:29:07 +02:00
. map (
( cycleDependencies , idx ) =>
2021-05-04 19:40:10 +02:00
'#' + idx + ':\n\t\t⬇️ ' + cycleDependencies . join ( '\n\t\t⬇️ ' )
2020-10-08 11:29:07 +02:00
)
. join ( '\n\t- ' ) } \ n \ n `
2021-05-04 19:40:10 +02:00
) . 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."
2020-12-01 10:17:27 +01:00
)
2020-10-08 11:29:07 +02:00
} )
} )