From 936f463bafcbe846f231f14ae29db20a920b1ca8 Mon Sep 17 00:00:00 2001 From: Kushal Pandya Date: Tue, 7 Feb 2017 21:39:40 +0530 Subject: [PATCH] Add tests for `gl.utils.isMetaClick` --- .../lib/utils/common_utils_spec.js.es6 | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/spec/javascripts/lib/utils/common_utils_spec.js.es6 b/spec/javascripts/lib/utils/common_utils_spec.js.es6 index fbb06f3948b..d10403cfb4e 100644 --- a/spec/javascripts/lib/utils/common_utils_spec.js.es6 +++ b/spec/javascripts/lib/utils/common_utils_spec.js.es6 @@ -73,5 +73,37 @@ require('~/lib/utils/common_utils'); expect(normalized[NGINX].nginx).toBe('ok'); }); }); + + describe('gl.utils.isMetaClick', () => { + it('should identify meta click on Windows/Linux', () => { + const e = { + metaKey: false, + ctrlKey: true, + which: 1, + }; + + expect(gl.utils.isMetaClick(e)).toBe(true); + }); + + it('should identify meta click on macOS', () => { + const e = { + metaKey: true, + ctrlKey: false, + which: 1, + }; + + expect(gl.utils.isMetaClick(e)).toBe(true); + }); + + it('should identify as meta click on middle-click or Mouse-wheel click', () => { + const e = { + metaKey: false, + ctrlKey: false, + which: 2, + }; + + expect(gl.utils.isMetaClick(e)).toBe(true); + }); + }); }); })();