forked from knaxus/problem-solving-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.test.js
26 lines (23 loc) · 796 Bytes
/
index.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
const Trie = require('../index');
const uniqueWordCount = require('.');
describe('Trie Unique Word Count', () => {
it('counts an empty trie', () => {
const trie = new Trie();
const wordCount = uniqueWordCount(trie.root);
expect(wordCount).toEqual(0);
});
it('counts unique words', () => {
const trie = new Trie();
const words = ['one', 'two', 'three', 'four'];
words.forEach((word) => trie.insert(word));
const wordCount = uniqueWordCount(trie.root);
expect(wordCount).toEqual(4);
});
it('does not count duplicate words', () => {
const trie = new Trie();
const words = ['one', 'one', 'two', 'three'];
words.forEach((word) => trie.insert(word));
const wordCount = uniqueWordCount(trie.root);
expect(wordCount).toEqual(3);
});
});