Skip to content

Commit 1126584

Browse files
committed
test: increase coverage
Signed-off-by: Andres Correa Casablanca <castarco@coderspirit.xyz>
1 parent 527b3f8 commit 1126584

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

src/tests/layouts.test.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,4 +424,57 @@ describe('computeCenter3Layout', () => {
424424
},
425425
})
426426
})
427+
428+
it('sets x=0.5,y=0 & x=0,y=1 & x=1,y=1 for tree with two children', () => {
429+
const result = computeCenter3Layout({
430+
data: { v: 42 },
431+
children: [
432+
{
433+
edgeData: {},
434+
node: { data: { v: 43 } },
435+
},
436+
{
437+
edgeData: {},
438+
node: { data: { v: 44 } },
439+
},
440+
],
441+
})
442+
443+
expect(result).toEqual({
444+
maxX: 1,
445+
maxY: 1,
446+
tree: {
447+
data: { v: 42 },
448+
children: [
449+
{
450+
edgeData: {},
451+
node: {
452+
data: { v: 43 },
453+
meta: {
454+
isRoot: false,
455+
isLeaf: true,
456+
pos: { x: 0, y: 1 },
457+
},
458+
},
459+
},
460+
{
461+
edgeData: {},
462+
node: {
463+
data: { v: 44 },
464+
meta: {
465+
isRoot: false,
466+
isLeaf: true,
467+
pos: { x: 1, y: 1 },
468+
},
469+
},
470+
},
471+
],
472+
meta: {
473+
isRoot: true,
474+
isLeaf: false,
475+
pos: { x: 0.5, y: 0 },
476+
},
477+
},
478+
})
479+
})
427480
})

0 commit comments

Comments
 (0)