Skip to content

Commit 325bc14

Browse files
authoredOct 25, 2019
Merge pull request knaxus#139 from niyonx/master
Added Unit Tests to Total Words in Tries closes knaxus#136
2 parents 2323351 + a53e144 commit 325bc14

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const totalWordsInTrie = require('./index')
2+
const Trie = require('../index');
3+
const assert = require('assert');
4+
5+
describe('Data Structure : Trie', () => {
6+
it('Should be class of type Trie', () => {
7+
assert.equal(typeof Trie.prototype.constructor, 'function');
8+
// expect(typeof Trie.prototype.constructor).toEqual('function');
9+
});
10+
11+
describe('Trie', () => {
12+
13+
it('Should return 6.', () => {
14+
let newTrie = new Trie();
15+
const words = ['bed', 'ball', 'apple', 'java', 'javascript', 'bed'];
16+
words.forEach(word => newTrie.insert(word));
17+
result = totalWordsInTrie.totalWords(newTrie.root);
18+
assert.equal(result, 6);
19+
});
20+
21+
it('Should return 0.', () => {
22+
let newTrie = new Trie();
23+
result = totalWordsInTrie.totalWords(newTrie.root);
24+
assert.equal(result, 0);
25+
});
26+
27+
it('Should return 6.', () => {
28+
let newTrie = new Trie();
29+
const words = ['bed', 'ball','', 'apple', 'java', 'javascript', 'bed'];
30+
words.forEach(word => newTrie.insert(word));
31+
result = totalWordsInTrie.totalWords(newTrie.root);
32+
assert.equal(result, 6);
33+
});
34+
});
35+
});

0 commit comments

Comments
 (0)