Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[No QA] [TS migration] Migrate 'TrieTest.js' test to TypeScript #36152

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
});
});
Loading