From 3633e04fcdc65ad8d15f47972c920c29d376362f Mon Sep 17 00:00:00 2001
From: Kushal Pandya <kushal@gitlab.com>
Date: Tue, 7 Feb 2017 21:40:31 +0530
Subject: [PATCH] Refactor tests for `#opensInNewTab`

---
 spec/javascripts/merge_request_tabs_spec.js | 23 +++------------------
 1 file changed, 3 insertions(+), 20 deletions(-)

diff --git a/spec/javascripts/merge_request_tabs_spec.js b/spec/javascripts/merge_request_tabs_spec.js
index 07f9797c229..72a05ce882c 100644
--- a/spec/javascripts/merge_request_tabs_spec.js
+++ b/spec/javascripts/merge_request_tabs_spec.js
@@ -62,7 +62,7 @@ require('vendor/jquery.scrollTo');
       });
     });
     describe('#opensInNewTab', function () {
-      it('opens page tab in a new browser tab with Ctrl+Click - Windows/Linux', function () {
+      beforeEach(function () {
         const commitsLink = '.commits-tab li a';
         const tabUrl = $(commitsLink).attr('href');
 
@@ -71,7 +71,8 @@ require('vendor/jquery.scrollTo');
           expect(url).toEqual(tabUrl);
           expect(name).toEqual('_blank');
         });
-
+      });
+      it('opens page tab in a new browser tab with Ctrl+Click - Windows/Linux', function () {
         this.class.clickTab({
           metaKey: false,
           ctrlKey: true,
@@ -80,15 +81,6 @@ require('vendor/jquery.scrollTo');
         });
       });
       it('opens page tab in a new browser tab with Cmd+Click - Mac', function () {
-        const commitsLink = '.commits-tab li a';
-        const tabUrl = $(commitsLink).attr('href');
-
-        spyOn($.fn, 'attr').and.returnValue(tabUrl);
-        spyOn(window, 'open').and.callFake(function (url, target) {
-          expect(url).toEqual(tabUrl);
-          expect(target).toEqual('_blank');
-        });
-
         this.class.clickTab({
           metaKey: true,
           ctrlKey: false,
@@ -97,15 +89,6 @@ require('vendor/jquery.scrollTo');
         });
       });
       it('opens page tab in a new browser tab with Middle-click - Mac/PC', function () {
-        const commitsLink = '.commits-tab li a';
-        const tabUrl = $(commitsLink).attr('href');
-
-        spyOn($.fn, 'attr').and.returnValue(tabUrl);
-        spyOn(window, 'open').and.callFake(function (url, target) {
-          expect(url).toEqual(tabUrl);
-          expect(target).toEqual('_blank');
-        });
-
         this.class.clickTab({
           metaKey: false,
           ctrlKey: false,
-- 
GitLab