import { BinarySearchTree } from"../../utility/algorithm/binary-search-tree";describe('BST', () => {constbst=newBinarySearchTree({ nodes: [2,5,3,8,7,4,9,12,23,10,1], });test('bst.handleHasValue should receive a number and return true or false if the value was exist', () => {constreceived= [2,5,3,8,7,4,9,12,23,10,1];for (constvof received) {expect(bst.handleHasValue(v)).toBeTruthy(); } });test('bst.handleInsert should receive a number and insert it to root', () => {constreceived= [100,200,300];for (constvof received) {bst.handleInsert(v);expect(bst.handleHasValue(v)).toBeTruthy(); } });test('bst.handleRemove should receive a number and remove it from root', () => {constreceived= [100,200,300];for (constvof received) {bst.handleRemove(v);expect(bst.handleHasValue(v)).toBeFalsy(); } });test('bst.handleGetDepth should return the whole tree depth when received undefined', () => {constexpected=6;expect(bst.handleGetDepth()).toBe(expected); });test('bst.handleGetDepth should receive a number and return its depth which was in tree', () => {constreceived= [5,7,23];constexpected= [2,4,6];for (const [i,v] ofreceived.entries()) {expect(bst.handleGetDepth(v)).toBe(expected[i]); } });test('bst.handleGetHeight should return whe whole tree height when received undefined', () => {constexpected=6;expect(bst.handleGetHeight()).toBe(expected); });test('bst.handleGetHeight should receive a number and return its height which was in tree', () => {constreceived= [5,7,23];constexpected= [5,1,1];for (const [i,v] ofreceived.entries()) {expect(bst.handleGetHeight(v)).toBe(expected[i]); } });test('bst.handleGetLeaves should return the collection of leaves node', () => {constexpected= [1,4,7,10,23];constresult=bst.handleGetLeaves();for (const [i,v] ofresult.entries()) {expect(v.value).toBe(expected[i]); } });test('bst.handleFrontOrderTraversal should ergodic the whole tree by using front-order and execute callback parameter', () => {constexpected= [2,1,5,3,4,8,7,9,12,10,23];let count =0;bst.handleFrontOrderTraversal((node) => {expect(node.value).toBe(expected[count]); count++; }); });test('bst.handleMiddleOrderTraversal should ergodic the whole tree by using middle-order and execute callback parameter', () => {constexpected= [1,2,5,3,4,8,7,9,12,10,23];let count =0;bst.handleMiddleOrderTraversal((node) => {expect(node.value).toBe(expected[count]); count++; }) });test('bst.handleBackOrderTraversal should ergodic the whole tree by using back-order and execute callback parameter', () => {constexpected= [1,5,3,4,8,7,9,12,10,23,2];let count =0;bst.handlBackOrderTraversal((node) => {expect(node.value).toBe(expected[count]); count++; }) });test('bst.handleGetRoot should return the whole tree', () => {constexpected= [2,1,5,3,4,8,7,9,12,10,23];let count =0;bst.handleFrontOrderTraversal((node) => {expect(node.value).toBe(expected[count]); count++; }); });test('bst.handleGetMaxValue should return the maximum node which was in tree', () => {constexpected=23;constresult=bst.handleGetMaxValue();expect(result).toBe(expected); });test('bst.handleGetMinValue should return the minimum node which was in tree', () => {constexpected=1;constresult=bst.handleGetMinValue();expect(result).toBe(expected); });});