16
import { assert } from "chai"
17
import { TreePath } from "../../src/tree/TreePath"
19
suite("TreePath", () => {
21
let root = new TreePath("root")
23
test("root path is root", () => assert(root.root === root))
24
test("root path depth", () => assert.equal(root.depth, 0))
25
test("root path has undefined parent", () => assert(root.parent === undefined))
26
test("root path to string", () => assert.equal(root.toString(), "/root"))
28
let parent = root.child("parent")
29
let current = parent.child("node")
31
test("tree path has root", () => assert(current.root === root))
32
test("tree path has parent", () => assert(current.parent === parent))
33
test("tree path depth", () => assert.equal(current.depth, 2))
34
test("tree path parent depth", () => assert.equal(current.parent?.depth, 1))
35
test("tree path to string", () => assert.equal(current.toString(), "/root/parent/node"))
37
let sibling = parent.child("sibling")
39
test("siblings has the same parents", () => assert(current.parent === sibling.parent))