mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 04:10:32 +00:00
WIP server side.
This commit is contained in:
31
server/tests/collection/NestedSet.test.js
Normal file
31
server/tests/collection/NestedSet.test.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import { expect } from '~/testInit';
|
||||
import NestedSet from '@/collection/NestedSet';
|
||||
|
||||
describe('NestedSet', () => {
|
||||
it('Should link parent and children nodes.', () => {
|
||||
const flattenArray = [
|
||||
{
|
||||
id: 1,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
parent_id: 1,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
parent_id: 1,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
parent_id: 3,
|
||||
},
|
||||
];
|
||||
|
||||
const collection = new NestedSet(flattenArray);
|
||||
|
||||
expect(collection[0].id).equals(1);
|
||||
expect(collection[0].children[0].id).equals(2);
|
||||
expect(collection[0].children[1].id).equals(3);
|
||||
expect(collection[0].children[1].children[0].id).equals(4);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user