-
Notifications
You must be signed in to change notification settings - Fork 340
/
dependency-graph.test.mjs
31 lines (25 loc) · 1.06 KB
/
dependency-graph.test.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import test from 'ava'
import { DependencyGraph } from '../project-graph/index.mjs'
/** @type {DependencyGraph} */
let graph
test.beforeEach(() => {
graph = new DependencyGraph()
graph.addDependency('tests/a.js', 'src/nested/a.js')
graph.addDependency('tests/c.js', 'src/c/index.js')
graph.addDependency('tests/c.js', 'tests/utils.js')
graph.addDependency('src/nested/a.js', 'src/nested/b.js')
graph.addDependency('src/nested/a.js', 'src/c/index.js')
graph.addDependency('src/c/index.js', 'src/d.js')
})
test('should test if all parents are affected by changing a src file on the bottom', (t) => {
t.deepEqual(
graph.affected(['src/d.js']),
new Set(['src/d.js', 'src/c/index.js', 'src/nested/a.js', 'tests/a.js', 'tests/c.js']),
)
})
test('should test only the root leaf is affected if the root one is passed', (t) => {
t.deepEqual([...graph.affected(['tests/a.js'])], ['tests/a.js'])
})
test('should test that nothing is affected if the passed file is not in the dependency graph', (t) => {
t.is(graph.affected(['some-markdown.md']).size, 0)
})