forked from knaxus/problem-solving-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtotal-words-in-trie.test.js
34 lines (30 loc) · 1.1 KB
/
total-words-in-trie.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
32
33
34
const assert = require('assert');
const totalWordsInTrie = require('./index');
const Trie = require('../index');
describe('Data Structure : Trie', () => {
it('Should be class of type Trie', () => {
assert.equal(typeof Trie.prototype.constructor, 'function');
// expect(typeof Trie.prototype.constructor).toEqual('function');
});
describe('Trie', () => {
it('Should return 6.', () => {
const newTrie = new Trie();
const words = ['bed', 'ball', 'apple', 'java', 'javascript', 'bed'];
words.forEach((word) => newTrie.insert(word));
const result = totalWordsInTrie(newTrie.root);
assert.equal(result, 6);
});
it('Should return 0.', () => {
const newTrie = new Trie();
const result = totalWordsInTrie(newTrie.root);
assert.equal(result, 0);
});
it('Should return 6.', () => {
const newTrie = new Trie();
const words = ['bed', 'ball', '', 'apple', 'java', 'javascript', 'bed'];
words.forEach((word) => newTrie.insert(word));
const result = totalWordsInTrie(newTrie.root);
assert.equal(result, 6);
});
});
});