Skip to content

Commit

Permalink
Merge pull request #36152 from VickyStash/ts-migration/trieTest
Browse files Browse the repository at this point in the history
[No QA] [TS migration] Migrate 'TrieTest.js' test to TypeScript
  • Loading branch information
bondydaa authored Feb 20, 2024
2 parents edca5e8 + b23edff commit eb26916
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 eb26916

Please sign in to comment.