Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-07-14 21:11:03 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-07-14 21:11:03 +0300
commit3da283df313b950685c1513b6b69a68de9c4ab11 (patch)
tree046edea54a5ea4945d7115ebb6552d55532eec38 /spec/frontend/lib
parent2aea9a0c91723b8800b016335930c59390cda7c9 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/lib')
-rw-r--r--spec/frontend/lib/utils/common_utils_spec.js34
1 files changed, 34 insertions, 0 deletions
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);
+ });
+ });
+ });
});