From b23edff9bd1e8613e113e88c192a607b305dfcb1 Mon Sep 17 00:00:00 2001 From: VickyStash Date: Thu, 8 Feb 2024 15:37:58 +0100 Subject: [PATCH] [TS migration] Migrate 'TrieTest.js' test --- tests/unit/{TrieTest.js => TrieTest.ts} | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) rename tests/unit/{TrieTest.js => TrieTest.ts} (91%) diff --git a/tests/unit/TrieTest.js b/tests/unit/TrieTest.ts similarity index 91% rename from tests/unit/TrieTest.js rename to tests/unit/TrieTest.ts index ad9958990ae4..d08fa8d7d520 100644 --- a/tests/unit/TrieTest.js +++ b/tests/unit/TrieTest.ts @@ -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', () => { @@ -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', () => { @@ -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'); }); });