forked from knaxus/problem-solving-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.test.js
31 lines (26 loc) · 874 Bytes
/
search.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const Trie = require('./index');
describe('Data Structure : Trie', () => {
describe('Trie Instance', () => {
it('Should be a class', () => {
expect(typeof Trie.prototype.constructor).toEqual('function');
});
});
describe('Trie API', () => {
const words = ['bed', 'ball', 'apple', 'java', 'javascript'];
let trie;
it('Should insert string', () => {
trie = new Trie();
words.forEach((word) => trie.insert(word));
});
it('Should return `True` if string present', () => {
expect(trie.search(words[0])).toEqual(true);
});
it('Should return `False` if string present', () => {
expect(trie.search('Ashu')).toEqual(false);
expect(trie.search('be')).toEqual(false);
});
it('Should return `False` if argument is not pass', () => {
expect(trie.search()).toEqual(false);
});
});
});