Commit 9574e789 authored by Remi  PLANEL's avatar Remi PLANEL

Update the tests

parent 9213df31
Pipeline #12914 failed with stages
in 2 minutes and 6 seconds
......@@ -2,31 +2,36 @@ import Phylogram from "../src/scripts/layout/phylogram";
import { RawPhyloTreeNode } from "../src/scripts/types";
describe("Test layout", () => {
const strokeRootWidth = 4;
const child10Name = "";
const data: RawPhyloTreeNode = {
"name": "root",
branchLength: 0,
nodes: {
node: {
r: 2,
fill: "green"
},
link: {
strokeWidth: strokeRootWidth
},
"children": [
{
"name": "child0",
branchLength: 0.5,
nodes: {
node: {
fill: "blue"
}
},
{
"name": "child1",
"name": "",
branchLength: 0.6,
nodes: {
node: {
r: 8,
fill: "red"
},
"children": [
{
"name": "child10",
"name": child10Name,
branchLength: 0.4
},
{
......@@ -43,7 +48,7 @@ describe("Test layout", () => {
const pointData = phylogramLayout(data);
const child0 = (pointData.children) ? pointData.children[0] : { y: false };
const child10 = pointData.leaves().reduce((acc, curr) => {
return (curr.data.name === "child10") ? curr : acc;
return (curr.data.name === child10Name) ? curr : acc;
}, pointData)
test("Root node middle height", () => {
expect(pointData.x).toBe(375);
......@@ -52,28 +57,31 @@ describe("Test layout", () => {
// Test X
if (child0) {
test("Child 0", () => {
expect(child0.y).toBe(500);
expect(child0.y).toBe(500 + strokeRootWidth / 2);
});
}
// Test y
test("child10", () => {
expect(child10.y).toBe(width);
})
if (child10) {
test("child10", () => {
expect(child10.y).toBe(width);
})
}
//test nodes object
test("root", () => {
const nodes = pointData.data.nodes;
const nodes = pointData.data.node;
if (nodes) {
expect(nodes.r).toBe(2);
}
})
test("root", () => {
expect(pointData.y).toBe(4);
})
// Change how define size
test("nodeSize", () => {
const xStep = 50;
const newData = phylogramLayout.nodeSize([xStep, 100])(data);
let yExpected = 0;
let yExpected = xStep / 2;
newData.leaves().forEach(leaf => {
expect(leaf.x).toBe(yExpected);
yExpected += xStep;
......
import Phylotree from "../src/scripts/component/tree/phylotree";
import Phylogram from "../src/scripts/layout/phylogram";
import { RawPhyloTreeNode, PhyloTreeNode } from "../src/scripts/types";
import { select, Selection } from "d3-selection";
import { select } from "d3-selection";
import { HierarchyPointNode } from "d3";
const rootName = "root";
......@@ -10,7 +10,7 @@ const rootFill = "green"
const data: RawPhyloTreeNode = {
"name": rootName,
branchLength: 0,
nodes: {
node: {
r: rootRadius,
fill: rootFill
},
......@@ -18,14 +18,14 @@ const data: RawPhyloTreeNode = {
{
"name": "child0",
branchLength: 0.5,
nodes: {
node: {
fill: "blue"
}
},
{
"name": "child1",
branchLength: 0.6,
nodes: {
node: {
r: 8,
fill: "red"
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment