summaryrefslogtreecommitdiff
path: root/spec/javascripts/bootstrap_linked_tabs_spec.js
diff options
context:
space:
mode:
authorMike Greiling <mike@pixelcog.com>2018-10-17 02:16:21 -0500
committerMike Greiling <mike@pixelcog.com>2018-10-17 11:18:17 -0500
commit024c31fe79b0e4026c9bff0802424efe6e127a4c (patch)
tree30c429f57324cecb928cdc775cb311f9996c740b /spec/javascripts/bootstrap_linked_tabs_spec.js
parentf666026d71ebefd70219d5078b1f0c83fa01f84d (diff)
downloadgitlab-ce-024c31fe79b0e4026c9bff0802424efe6e127a4c.tar.gz
Remove superfluous IIFEs
Diffstat (limited to 'spec/javascripts/bootstrap_linked_tabs_spec.js')
-rw-r--r--spec/javascripts/bootstrap_linked_tabs_spec.js98
1 files changed, 48 insertions, 50 deletions
diff --git a/spec/javascripts/bootstrap_linked_tabs_spec.js b/spec/javascripts/bootstrap_linked_tabs_spec.js
index 0bf6c9820fa..c52141dbf2d 100644
--- a/spec/javascripts/bootstrap_linked_tabs_spec.js
+++ b/spec/javascripts/bootstrap_linked_tabs_spec.js
@@ -1,69 +1,67 @@
import LinkedTabs from '~/lib/utils/bootstrap_linked_tabs';
-(() => {
- describe('Linked Tabs', () => {
- preloadFixtures('static/linked_tabs.html.raw');
+describe('Linked Tabs', () => {
+ preloadFixtures('static/linked_tabs.html.raw');
+ beforeEach(() => {
+ loadFixtures('static/linked_tabs.html.raw');
+ });
+
+ describe('when is initialized', () => {
beforeEach(() => {
- loadFixtures('static/linked_tabs.html.raw');
+ spyOn(window.history, 'replaceState').and.callFake(function() {});
});
- describe('when is initialized', () => {
- beforeEach(() => {
- spyOn(window.history, 'replaceState').and.callFake(function() {});
+ it('should activate the tab correspondent to the given action', () => {
+ const linkedTabs = new LinkedTabs({
+ // eslint-disable-line
+ action: 'tab1',
+ defaultAction: 'tab1',
+ parentEl: '.linked-tabs',
});
- it('should activate the tab correspondent to the given action', () => {
- const linkedTabs = new LinkedTabs({
- // eslint-disable-line
- action: 'tab1',
- defaultAction: 'tab1',
- parentEl: '.linked-tabs',
- });
+ expect(document.querySelector('#tab1').classList).toContain('active');
+ });
- expect(document.querySelector('#tab1').classList).toContain('active');
+ it('should active the default tab action when the action is show', () => {
+ const linkedTabs = new LinkedTabs({
+ // eslint-disable-line
+ action: 'show',
+ defaultAction: 'tab1',
+ parentEl: '.linked-tabs',
});
- it('should active the default tab action when the action is show', () => {
- const linkedTabs = new LinkedTabs({
- // eslint-disable-line
- action: 'show',
- defaultAction: 'tab1',
- parentEl: '.linked-tabs',
- });
-
- expect(document.querySelector('#tab1').classList).toContain('active');
- });
+ expect(document.querySelector('#tab1').classList).toContain('active');
});
+ });
- describe('on click', () => {
- it('should change the url according to the clicked tab', () => {
- const historySpy = spyOn(window.history, 'replaceState').and.callFake(() => {});
+ describe('on click', () => {
+ it('should change the url according to the clicked tab', () => {
+ const historySpy = spyOn(window.history, 'replaceState').and.callFake(() => {});
- const linkedTabs = new LinkedTabs({
- action: 'show',
- defaultAction: 'tab1',
- parentEl: '.linked-tabs',
- });
+ const linkedTabs = new LinkedTabs({
+ action: 'show',
+ defaultAction: 'tab1',
+ parentEl: '.linked-tabs',
+ });
- const secondTab = document.querySelector('.linked-tabs li:nth-child(2) a');
- const newState =
- secondTab.getAttribute('href') +
- linkedTabs.currentLocation.search +
- linkedTabs.currentLocation.hash;
+ const secondTab = document.querySelector('.linked-tabs li:nth-child(2) a');
+ const newState =
+ secondTab.getAttribute('href') +
+ linkedTabs.currentLocation.search +
+ linkedTabs.currentLocation.hash;
- secondTab.click();
+ secondTab.click();
- if (historySpy) {
- expect(historySpy).toHaveBeenCalledWith(
- {
- url: newState,
- },
- document.title,
- newState,
- );
- }
- });
+ if (historySpy) {
+ expect(historySpy).toHaveBeenCalledWith(
+ {
+ url: newState,
+ },
+ document.title,
+ newState,
+ );
+ }
});
});
-})();
+});