04dc2b76d7
* master: (181 commits) Fixed adding to list bug Remove unnecessary queries for .atom and .json in Dashboard::ProjectsController#index Fixed modal lists dropdown not updating when list is deleted Fixed remove btn error after creating new issue in list Removed duplicated test Removed Masonry, instead uses groups of data Uses mixins for repeated functions Fixed up specs Props use objects with required & type values Removes labels instead of closing issue when clicking remove button Fixed JS lint errors Fixed issue card spec Added webkit CSS properties Fixed bug with empty state showing after search Fixed users href path being incorrect Fixed bug where 2 un-selected issues would stay on selected tab Fixed DB schema Changed how components are added in objects Added remove button Add optional id property to the issue schema Fixed issue link href Disabled add issues button if no lists exist ...
71 lines
2.2 KiB
JavaScript
71 lines
2.2 KiB
JavaScript
require('~/lib/utils/bootstrap_linked_tabs');
|
|
|
|
(() => {
|
|
// TODO: remove this hack!
|
|
// PhantomJS causes spyOn to panic because replaceState isn't "writable"
|
|
let phantomjs;
|
|
try {
|
|
phantomjs = !Object.getOwnPropertyDescriptor(window.history, 'replaceState').writable;
|
|
} catch (err) {
|
|
phantomjs = false;
|
|
}
|
|
|
|
describe('Linked Tabs', () => {
|
|
preloadFixtures('static/linked_tabs.html.raw');
|
|
|
|
beforeEach(() => {
|
|
loadFixtures('static/linked_tabs.html.raw');
|
|
});
|
|
|
|
describe('when is initialized', () => {
|
|
beforeEach(() => {
|
|
if (!phantomjs) {
|
|
spyOn(window.history, 'replaceState').and.callFake(function () {});
|
|
}
|
|
});
|
|
|
|
it('should activate the tab correspondent to the given action', () => {
|
|
const linkedTabs = new window.gl.LinkedTabs({ // eslint-disable-line
|
|
action: 'tab1',
|
|
defaultAction: 'tab1',
|
|
parentEl: '.linked-tabs',
|
|
});
|
|
|
|
expect(document.querySelector('#tab1').classList).toContain('active');
|
|
});
|
|
|
|
it('should active the default tab action when the action is show', () => {
|
|
const linkedTabs = new window.gl.LinkedTabs({ // eslint-disable-line
|
|
action: 'show',
|
|
defaultAction: 'tab1',
|
|
parentEl: '.linked-tabs',
|
|
});
|
|
|
|
expect(document.querySelector('#tab1').classList).toContain('active');
|
|
});
|
|
});
|
|
|
|
describe('on click', () => {
|
|
it('should change the url according to the clicked tab', () => {
|
|
const historySpy = !phantomjs && spyOn(history, 'replaceState').and.callFake(() => {});
|
|
|
|
const linkedTabs = new window.gl.LinkedTabs({ // eslint-disable-line
|
|
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;
|
|
|
|
secondTab.click();
|
|
|
|
if (historySpy) {
|
|
expect(historySpy).toHaveBeenCalledWith({
|
|
url: newState,
|
|
}, document.title, newState);
|
|
}
|
|
});
|
|
});
|
|
});
|
|
})();
|