mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 11:30:13 +08:00
feat: calculate layer
This commit is contained in:
1 parent
c92a2e1d70
commit
fae2d8199d
2 files changed
+80
No files matched your search
@@ -0,0 +1,50 @@
|
||||
import DAG from './dag.js'
|
||||
|
||||
describe('dag', () => {
|
||||
const data = [
|
||||
{
|
||||
_id: 'helloworld',
|
||||
title: 'Hello, Linux World!',
|
||||
requirements: [],
|
||||
},
|
||||
{
|
||||
_id: 'spell',
|
||||
title: 'Learn to spell',
|
||||
requirements: ['helloworld'],
|
||||
},
|
||||
{
|
||||
_id: 'discover',
|
||||
title: 'Discover the World!',
|
||||
requirements: ['spell'],
|
||||
},
|
||||
{
|
||||
_id: 'read',
|
||||
title: 'Read the File',
|
||||
requirements: ['spell'],
|
||||
},
|
||||
{
|
||||
_id: 'remove',
|
||||
requirements: ['read', 'discover'],
|
||||
},
|
||||
{
|
||||
_id: 'move',
|
||||
requirements: ['helloworld'],
|
||||
},
|
||||
{
|
||||
_id: 'copy',
|
||||
requirements: ['remove', 'move'],
|
||||
},
|
||||
]
|
||||
|
||||
it('should set layers', () => {
|
||||
const dag = new DAG(data)
|
||||
dag.format()
|
||||
expect(dag.get('helloworld').layer).toBe(1)
|
||||
expect(dag.get('spell').layer).toBe(2)
|
||||
expect(dag.get('move').layer).toBe(2)
|
||||
expect(dag.get('read').layer).toBe(3)
|
||||
expect(dag.get('discover').layer).toBe(3)
|
||||
expect(dag.get('remove').layer).toBe(4)
|
||||
expect(dag.get('copy').layer).toBe(5)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user