Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 325bc14

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

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
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)

AltStyle によって変換されたページ (->オリジナル) /