From 3da283df313b950685c1513b6b69a68de9c4ab11 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Fri, 14 Jul 2023 18:11:03 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- spec/frontend/lib/utils/common_utils_spec.js | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'spec/frontend/lib') diff --git a/spec/frontend/lib/utils/common_utils_spec.js b/spec/frontend/lib/utils/common_utils_spec.js index b4ec00ab766..444d4a96f9c 100644 --- a/spec/frontend/lib/utils/common_utils_spec.js +++ b/spec/frontend/lib/utils/common_utils_spec.js @@ -1140,4 +1140,38 @@ describe('common_utils', () => { expect(result).toEqual([{ hello: '' }, { helloWorld: '' }]); }); }); + + describe('isCurrentUser', () => { + describe('when user is not signed in', () => { + it('returns `false`', () => { + window.gon.current_user_id = null; + + expect(commonUtils.isCurrentUser(1)).toBe(false); + }); + }); + + describe('when current user id does not match the provided user id', () => { + it('returns `false`', () => { + window.gon.current_user_id = 2; + + expect(commonUtils.isCurrentUser(1)).toBe(false); + }); + }); + + describe('when current user id matches the provided user id', () => { + it('returns `true`', () => { + window.gon.current_user_id = 1; + + expect(commonUtils.isCurrentUser(1)).toBe(true); + }); + }); + + describe('when provided user id is a string and it matches current user id', () => { + it('returns `true`', () => { + window.gon.current_user_id = 1; + + expect(commonUtils.isCurrentUser('1')).toBe(true); + }); + }); + }); }); -- cgit v1.2.3