aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHenry Jameson <me@hjkos.com>2020-01-20 01:44:11 +0200
committerHenry Jameson <me@hjkos.com>2020-01-20 01:44:11 +0200
commit2b36a62c5600738737e0fda4e0fc92e6e1f59c33 (patch)
treef0e78be6dd9ef702093469822363536ca0190737 /test
parent6e1c538e4182263a75fb65b0f3c5d1ad9de94541 (diff)
fix tests, integrate depenentless sorting into toposort for easier testing and
better guarantees
Diffstat (limited to 'test')
-rw-r--r--test/unit/specs/services/theme_data/theme_data.spec.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/test/unit/specs/services/theme_data/theme_data.spec.js b/test/unit/specs/services/theme_data/theme_data.spec.js
index 507905eb..d8a04ba7 100644
--- a/test/unit/specs/services/theme_data/theme_data.spec.js
+++ b/test/unit/specs/services/theme_data/theme_data.spec.js
@@ -72,8 +72,16 @@ describe('topoSort', () => {
expect(out.indexOf('layer2A')).to.be.below(out.indexOf('layer3AB'))
expect(out.indexOf('layer2B')).to.be.below(out.indexOf('layer3AB'))
})
+
+ it('dependentless nodes should be first', () => {
+ const out = topoSort(fixture2, (node, inheritance) => inheritance[node])
+ // This basically checks all ordering that matters
+ expect(out.indexOf('layerA')).to.eql(0)
+ expect(out.indexOf('layerB')).to.eql(1)
+ })
+
it('ignores cyclic dependencies', () => {
- const out = topoSort({ a: 'b', b: 'a', c: 'a' }, (node, inheritance) => inheritance[node])
+ const out = topoSort({ a: 'b', b: 'a', c: 'a' }, (node, inheritance) => [inheritance[node]])
expect(out.indexOf('a')).to.be.below(out.indexOf('c'))
})
})