Files
Rahul Raj c9701e8a4c merge: Improving the coding standard for AvLTree Data Structure (#882)
* Improving the coding standard for AvLTree Data Structure

* Test case creation for AVLTree

~ Created test cases for AVL Tree
~ Indentation fix for AVLTree.js

* Auto-update DIRECTORY.md

* Change in logic for data list

* Style fix based on standard.js

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-02-17 14:08:26 +05:30

31 lines
725 B
JavaScript

import { AVLTree } from '../AVLTree'
describe('AVLTree Implementation: ', () => {
const avlTree = new AVLTree()
const dataList = []
const demoData = [1, 4, 6, 22, 7, 99, 4, 66, 77, 98]
beforeAll(() => {
demoData.forEach(item => {
if (avlTree.add(item)) {
dataList.push(item)
}
})
})
it('checks if element is inserted properly', () => {
expect(dataList.length).toEqual(avlTree.size)
})
it('search if inserted element is present', () => {
demoData.forEach(data => {
expect(avlTree.find(data)).toBeTruthy()
})
})
it('deletes the inserted element', () => {
const deleteElement = dataList[3]
expect(avlTree.remove(deleteElement)).toBeTruthy()
})
})