From 6fc83d5c0a882f41027994c7dd4382859895ce9a Mon Sep 17 00:00:00 2001 From: Roji Philip Date: Mon, 18 Dec 2023 20:22:14 +0530 Subject: [PATCH 1/2] use capture groups for regex --- src/libs/UserUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/UserUtils.ts b/src/libs/UserUtils.ts index e95b62cc2437..ba19002345e7 100644 --- a/src/libs/UserUtils.ts +++ b/src/libs/UserUtils.ts @@ -105,8 +105,8 @@ function getDefaultAvatar(accountID = -1, avatarURL?: string): React.FC Date: Tue, 19 Dec 2023 17:35:38 +0530 Subject: [PATCH 2/2] unit test for default avatar based on url --- tests/unit/UserUtilsTest.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 tests/unit/UserUtilsTest.js diff --git a/tests/unit/UserUtilsTest.js b/tests/unit/UserUtilsTest.js new file mode 100644 index 000000000000..f0f20fc6d4cb --- /dev/null +++ b/tests/unit/UserUtilsTest.js @@ -0,0 +1,9 @@ +import * as UserUtils from '../../src/libs/UserUtils'; + +describe('UserUtils', () => { + it('should return the default avatar from the avatar url', () => { + const avatarURL = 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_7.png'; + const defaultAvatar = UserUtils.getDefaultAvatar(1, avatarURL); + expect(typeof defaultAvatar).toBe('function'); + }); +});