summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKushal Pandya <kushal@gitlab.com>2017-02-23 17:36:03 +0530
committerKushal Pandya <kushal@gitlab.com>2017-02-23 19:46:41 +0530
commitc7445a40a26b3945e51e99356f1ca4e8cd5b5e97 (patch)
treef41643950e9eda2fa2d12b512c32b032596a39a1
parenta77b40d45e2f474a3d2401125b7b89379a7a7dd5 (diff)
downloadgitlab-ce-27819-remove-repeating-spies.tar.gz
Remove repeating spies27819-remove-repeating-spies
-rw-r--r--spec/javascripts/merge_request_tabs_spec.js30
1 files changed, 10 insertions, 20 deletions
diff --git a/spec/javascripts/merge_request_tabs_spec.js b/spec/javascripts/merge_request_tabs_spec.js
index 7506e6ab49e..6ca3f3df381 100644
--- a/spec/javascripts/merge_request_tabs_spec.js
+++ b/spec/javascripts/merge_request_tabs_spec.js
@@ -73,26 +73,25 @@ require('vendor/jquery.scrollTo');
spyOn($.fn, 'attr').and.returnValue(tabUrl);
});
+ function expectWindowOpenCall(url, name) {
+ expect(url).toEqual(tabUrl);
+ expect(name).toEqual(windowTarget);
+ }
+
describe('meta click', () => {
beforeEach(function () {
spyOn(gl.utils, 'isMetaClick').and.returnValue(true);
});
it('opens page when commits link is clicked', function () {
- spyOn(window, 'open').and.callFake(function (url, name) {
- expect(url).toEqual(tabUrl);
- expect(name).toEqual(windowTarget);
- });
+ spyOn(window, 'open').and.callFake(expectWindowOpenCall);
this.class.bindEvents();
document.querySelector('.merge-request-tabs .commits-tab a').click();
});
it('opens page when commits badge is clicked', function () {
- spyOn(window, 'open').and.callFake(function (url, name) {
- expect(url).toEqual(tabUrl);
- expect(name).toEqual(windowTarget);
- });
+ spyOn(window, 'open').and.callFake(expectWindowOpenCall);
this.class.bindEvents();
document.querySelector('.merge-request-tabs .commits-tab a .badge').click();
@@ -100,10 +99,7 @@ require('vendor/jquery.scrollTo');
});
it('opens page tab in a new browser tab with Ctrl+Click - Windows/Linux', function () {
- spyOn(window, 'open').and.callFake(function (url, name) {
- expect(url).toEqual(tabUrl);
- expect(name).toEqual(windowTarget);
- });
+ spyOn(window, 'open').and.callFake(expectWindowOpenCall);
this.class.clickTab({
metaKey: false,
@@ -113,10 +109,7 @@ require('vendor/jquery.scrollTo');
});
});
it('opens page tab in a new browser tab with Cmd+Click - Mac', function () {
- spyOn(window, 'open').and.callFake(function (url, name) {
- expect(url).toEqual(tabUrl);
- expect(name).toEqual(windowTarget);
- });
+ spyOn(window, 'open').and.callFake(expectWindowOpenCall);
this.class.clickTab({
metaKey: true,
@@ -126,10 +119,7 @@ require('vendor/jquery.scrollTo');
});
});
it('opens page tab in a new browser tab with Middle-click - Mac/PC', function () {
- spyOn(window, 'open').and.callFake(function (url, name) {
- expect(url).toEqual(tabUrl);
- expect(name).toEqual(windowTarget);
- });
+ spyOn(window, 'open').and.callFake(expectWindowOpenCall);
this.class.clickTab({
metaKey: false,