Skip to content

Commit 69596a5

Browse files
Test complex trie build
1 parent 8169ffb commit 69596a5

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/utils/trie.spec.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,44 @@ describe('build', () => {
9393
fo: { o: {}, O: {} },
9494
});
9595
});
96+
97+
it('handles complex words', () => {
98+
const words = [
99+
'Maine',
100+
'Maryland',
101+
'Massachusetts',
102+
'Michigan',
103+
'Minnesota',
104+
'Mississippi',
105+
'Missouri',
106+
'Montana',
107+
'Nebraska',
108+
'Nevada',
109+
'New Hampshire',
110+
'New Jersey',
111+
'New Mexico',
112+
'New York',
113+
'North Carolina',
114+
'North Dakota',
115+
'Ohio',
116+
'Oklahoma',
117+
'Oregon',
118+
];
119+
expect(build(words)).toEqual({
120+
M: {
121+
a: { ine: {}, ryland: {}, ssachusetts: {} },
122+
i: { chigan: {}, nnesota: {}, ss: { issippi: {}, ouri: {} } },
123+
ontana: {},
124+
},
125+
N: {
126+
e: {
127+
braska: {},
128+
vada: {},
129+
'w ': { Hampshire: {}, Jersey: {}, Mexico: {}, York: {} },
130+
},
131+
'orth ': { Carolina: {}, Dakota: {} },
132+
},
133+
O: { hio: {}, klahoma: {}, regon: {} },
134+
});
135+
});
96136
});

0 commit comments

Comments
 (0)