WIP ⚙️ Detect cycles: test for cycles using @dagrejs/graphlib
parent
47f1620e5d
commit
59d4be7d4f
|
@ -1,11 +1,26 @@
|
|||
<<<<<<< HEAD:mon-entreprise/test/cycles.test.js
|
||||
import { parseRules, buildRulesDependencies } from 'publicodes'
|
||||
=======
|
||||
import graphlib from '@dagrejs/graphlib'
|
||||
import { expect } from 'chai'
|
||||
import { buildRulesDependencies } from 'Engine/cyclesLib'
|
||||
import parseRules from 'Engine/parseRules'
|
||||
>>>>>>> cde4da75... WIP ⚙️ Detect cycles: test for cycles using @dagrejs/graphlib:test/cycles.test.js
|
||||
import rules from 'Rules'
|
||||
|
||||
describe('Graph', () => {
|
||||
it('should get a graph', () => {
|
||||
debugger // Keep this for allowing deactivating other debugger statements via the Chrome inspector
|
||||
describe('DottedNames graph', () => {
|
||||
it("shouldn't have cycles", () => {
|
||||
let parsedRules = parseRules(rules)
|
||||
let ruleDependencies = buildRulesDependencies(parsedRules)
|
||||
console.log(ruleDependencies)
|
||||
let g = new graphlib.Graph()
|
||||
|
||||
ruleDependencies.forEach(([ruleDottedName, dependenciesDottedNames]) => {
|
||||
dependenciesDottedNames.forEach(depDottedName => {
|
||||
g.setNode(ruleDottedName, depDottedName)
|
||||
})
|
||||
})
|
||||
const cycles = graphlib.alg.findCycles(g)
|
||||
|
||||
expect(cycles).to.be.an('array').that.is.empty
|
||||
})
|
||||
})
|
||||
|
|
|
@ -899,6 +899,13 @@
|
|||
debug "^3.1.0"
|
||||
lodash.once "^4.1.1"
|
||||
|
||||
"@dagrejs/graphlib@^2.1.4":
|
||||
version "2.1.4"
|
||||
resolved "https://registry.yarnpkg.com/@dagrejs/graphlib/-/graphlib-2.1.4.tgz#86c70e4f073844a2f4ada254c8c7b88a6bdacdb1"
|
||||
integrity sha512-QCg9sL4uhjn468FDEsb/S9hS2xUZSrv/+dApb1Ze5VKO96pTXKNJZ6MGhIpgWkc1TVhbVGH9/7rq/Mf8/jWicw==
|
||||
dependencies:
|
||||
lodash "^4.11.1"
|
||||
|
||||
"@emotion/cache@^10.0.27":
|
||||
version "10.0.29"
|
||||
resolved "https://registry.yarnpkg.com/@emotion/cache/-/cache-10.0.29.tgz#87e7e64f412c060102d589fe7c6dc042e6f9d1e0"
|
||||
|
@ -7493,7 +7500,7 @@ lodash.uniq@^4.5.0:
|
|||
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
|
||||
integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=
|
||||
|
||||
lodash@4.17.15, lodash@^4.0.1, lodash@^4.15.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0, lodash@~4.17.4:
|
||||
lodash@4.17.15, lodash@^4.0.1, lodash@^4.11.1, lodash@^4.15.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0, lodash@~4.17.4:
|
||||
version "4.17.15"
|
||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
|
||||
integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==
|
||||
|
|
Loading…
Reference in New Issue