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:
Diffstat (limited to 'spec/frontend/lib/utils/common_utils_spec.js')
-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);
+ });
+ });
+ });
});