From 57eb161554195b8a477210a4e41882d10a43973e Mon Sep 17 00:00:00 2001 From: crisnicandrei <62384997+crisnicandrei@users.noreply.github.com> Date: Tue, 26 Sep 2023 12:49:37 +0300 Subject: [PATCH] Rewrote the tests to comply to the new behaviour --- .../search/services/search.service.spec.ts | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/app/search/services/search.service.spec.ts b/src/app/search/services/search.service.spec.ts index 63f53fa82..b998c5046 100644 --- a/src/app/search/services/search.service.spec.ts +++ b/src/app/search/services/search.service.spec.ts @@ -110,6 +110,32 @@ describe('SearchService', () => { expect(search[0]).toBe(expectedSearch); expect(search[1]).toEqual(expectedTags); } + + it('removes the first and last quotation marks from tag names', () => { + tags.setTags([ + { name: 'Potato', tagId: 0 }, + { name: '"Potato"', tagId: 1 }, + ]); + const searchTokens = service.parseSearchTerm('tag:""Potato""'); + expect(searchTokens[1].length).toBe(1); + expect(searchTokens[1][0].tagId).toBe(1); + }); + + it('handles tag edge cases', () => { + tags.setTags([{ name: 'tag:Test' }]); + expectSearchToBe( + service.parseSearchTerm('tag:"tag:"Test""'), + 'tag:"tag:"Test""', + [] + ); + }); + + it('handles returns the tags correctly if they have quotation marks', () => { + tags.setTags([{ name: 'tag:"Test"' }]); + expectSearchToBe(service.parseSearchTerm('tag:"tag:"Test""'), undefined, [ + { name: 'tag:"Test"' }, + ]); + }); }); describe('getResultsInCurrentFolder', () => {