Skip to content

Commit 2877788

Browse files
committed
chore: better empty tree handling
1 parent dd02c5c commit 2877788

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Diff for: Data-Structures/Tree/test/BinarySearchTree.test.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ describe('Binary Search Tree', () => {
5959
})
6060

6161
test('should handle empty tree gracefully', () => {
62-
expect(tree.search(22)).toBeNull()
63-
tree.removeValue(22) // Should not throw
62+
const newTree = new Tree()
63+
newTree.removeValue(22) // Should not throw
64+
expect(newTree.search(22)).toBeNull()
6465
})
6566
})

0 commit comments

Comments
 (0)