| 741 | } |
| 742 | |
| 743 | function assertTreeEqual(expected: TreeNode, actualValue: unknown): void { |
| 744 | assert.ok( |
| 745 | actualValue != null && typeof actualValue === "object", |
| 746 | "tree payload must decode to an object", |
| 747 | ); |
| 748 | const actual = actualValue as TreeNode; |
| 749 | assert.equal(actual.id, expected.id, "tree root id mismatch"); |
| 750 | assert.equal(actual.name, expected.name, "tree root name mismatch"); |
| 751 | assert.equal( |
| 752 | actual.children.length, |
| 753 | expected.children.length, |
| 754 | "tree children size mismatch", |
| 755 | ); |
| 756 | assert.equal(expected.children.length, 3, "expected tree fixture drift"); |
| 757 | assert.strictEqual( |
| 758 | expected.children[0], |
| 759 | expected.children[1], |
| 760 | "expected tree shared child drift", |
| 761 | ); |
| 762 | assert.notStrictEqual( |
| 763 | expected.children[0], |
| 764 | expected.children[2], |
| 765 | "expected tree distinct child drift", |
| 766 | ); |
| 767 | assert.equal( |
| 768 | actual.children[0].id, |
| 769 | expected.children[0].id, |
| 770 | "tree first child id mismatch", |
| 771 | ); |
| 772 | assert.equal( |
| 773 | actual.children[0].name, |
| 774 | expected.children[0].name, |
| 775 | "tree first child name mismatch", |
| 776 | ); |
| 777 | assert.equal( |
| 778 | actual.children[2].id, |
| 779 | expected.children[2].id, |
| 780 | "tree third child id mismatch", |
| 781 | ); |
| 782 | assert.equal( |
| 783 | actual.children[2].name, |
| 784 | expected.children[2].name, |
| 785 | "tree third child name mismatch", |
| 786 | ); |
| 787 | assert.strictEqual( |
| 788 | actual.children[0], |
| 789 | actual.children[1], |
| 790 | "tree shared child mismatch", |
| 791 | ); |
| 792 | assert.notStrictEqual( |
| 793 | actual.children[0], |
| 794 | actual.children[2], |
| 795 | "tree distinct child mismatch", |
| 796 | ); |
| 797 | assert.strictEqual( |
| 798 | actual.children[0].parent, |
| 799 | actual.children[2], |
| 800 | "tree parent back-pointer mismatch", |