Skip to content

Commit 227ec59

Browse files
committed
add unit tests
1 parent 1df6825 commit 227ec59

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

tests/unit/UserUtilsTest.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as defaultAvatars from '@components/Icon/DefaultAvatars';
12
import * as UserUtils from '@src/libs/UserUtils';
23

34
describe('UserUtils', () => {
@@ -6,12 +7,22 @@ describe('UserUtils', () => {
67
const defaultAvatar = UserUtils.getAvatar(avatarURL, 1);
78

89
expect(typeof defaultAvatar).toBe('function');
10+
11+
const defaultAvatarUrl = UserUtils.getAvatarUrl(avatarURL, 1);
12+
13+
expect(defaultAvatarUrl).toBe('https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_7.png');
14+
// Both defaultAvatar and defaultAvatarUrl must be `defaultAvatars.Avatar7`
15+
expect(defaultAvatar === defaultAvatars.Avatar7).toBeTruthy();
916
});
1017

1118
it('should return the same url if url is not for default avatar', () => {
1219
const avatarURL = 'https://test.com/images/some_avatar.png';
1320
const avatar = UserUtils.getAvatar(avatarURL, 1);
1421

1522
expect(avatar).toEqual('https://test.com/images/some_avatar.png');
23+
24+
const avatarUrl = UserUtils.getAvatarUrl(avatarURL, 1);
25+
26+
expect(avatarUrl).toEqual('https://test.com/images/some_avatar.png');
1627
});
1728
});

0 commit comments

Comments
 (0)