1
+ const totalWordsInTrie = require ( './index' )
2
+ const Trie = require ( '../index' ) ;
3
+ var 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