Created
February 12, 2022 16:07
-
-
Save thmsobrmlr/732ecf958f600ec38e89c4e8ff57f3dd to your computer and use it in GitHub Desktop.
Revisions
-
thmsobrmlr created this gist
Feb 12, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ import removeAppNameFromProductTitle from './removeAppNameFromProductTitle'; describe('removeAppNameFromProductTitle', () => { it('returns title without app name', () => { const title = 'my test'; const result = removeAppNameFromProductTitle(title); expect(result).toEqual('my test'); }); it('removes app name from title', () => { const title = 'my test (com.test.myapp)'; const result = removeAppNameFromProductTitle(title); expect(result).toEqual('my test'); }); it('removes app name from title with parantheses', () => { const title = 'my test (a good test) (com.test.myapp)'; const result = removeAppNameFromProductTitle(title); expect(result).toEqual('my test (a good test)'); }); it('removes app name with nested parantheses from title', () => { const title = 'my test (com.test.myapp (unreviewed))'; const result = removeAppNameFromProductTitle(title); expect(result).toEqual('my test'); }); it('removes app name with nested parantheses from title with parantheses', () => { const title = 'my test (a good test) (com.test.myapp (unreviewed))'; const result = removeAppNameFromProductTitle(title); expect(result).toEqual('my test (a good test)'); }); }); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ const removeAppNameFromProductTitle = (title: string) => { const regex = /( \([^()]*\)$)|( \([^)]*\)\)$)/im; return title.replace(regex, ''); }; export default removeAppNameFromProductTitle;