Skip to content

Commit

Permalink
[TS migration] Migrate 'TrieTest.js' test
Browse files Browse the repository at this point in the history
  • Loading branch information
VickyStash committed Feb 8, 2024
1 parent 304befd commit b23edff
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/unit/TrieTest.js → tests/unit/TrieTest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Trie from '../../src/libs/Trie';
import Trie from '@src/libs/Trie';

describe('Trie', () => {
it('Test if a node can be found in the Trie', () => {
Expand All @@ -8,8 +8,8 @@ describe('Trie', () => {
wordTrie.add('joy', {code: '😂'});
wordTrie.add('rofl', {code: '🤣'});
expect(wordTrie.search('eyes')).toBeNull();
expect(wordTrie.search('joy').metaData).toEqual({code: '😂'});
expect(wordTrie.search('gRiN').metaData).toEqual({code: '😁'});
expect(wordTrie.search('joy')?.metaData).toEqual({code: '😂'});
expect(wordTrie.search('gRiN')?.metaData).toEqual({code: '😁'});
});

it('Test finding all leaf nodes starting with a substring', () => {
Expand Down Expand Up @@ -65,13 +65,13 @@ describe('Trie', () => {
const wordTrie = new Trie();
wordTrie.add('John', {code: '👨🏼'});
wordTrie.update('John', {code: '👨🏻'});
expect(wordTrie.search('John').metaData).toEqual({code: '👨🏻'});
expect(wordTrie.search('John')?.metaData).toEqual({code: '👨🏻'});
});

it('Test throwing an error when try to update a word that does not exist in the Trie.', () => {
const wordTrie = new Trie();
expect(() => {
wordTrie.update('smile');
wordTrie.update('smile', {});
}).toThrow('Word does not exist in the Trie');
});
});

0 comments on commit b23edff

Please sign in to comment.