debian-mirror-gitlab/spec/javascripts/settings_panels_spec.js

46 lines
1.3 KiB
JavaScript
Raw Normal View History

2018-12-13 13:39:08 +05:30
import $ from 'jquery';
2018-03-27 19:54:05 +05:30
import initSettingsPanels from '~/settings_panels';
describe('Settings Panels', () => {
2018-12-13 13:39:08 +05:30
preloadFixtures('groups/edit.html.raw');
2018-03-27 19:54:05 +05:30
beforeEach(() => {
2018-12-13 13:39:08 +05:30
loadFixtures('groups/edit.html.raw');
2018-03-27 19:54:05 +05:30
});
describe('initSettingsPane', () => {
afterEach(() => {
2018-11-08 19:23:39 +05:30
window.location.hash = '';
2018-03-27 19:54:05 +05:30
});
it('should expand linked hash fragment panel', () => {
2018-12-13 13:39:08 +05:30
window.location.hash = '#js-general-settings';
2018-03-27 19:54:05 +05:30
2018-12-13 13:39:08 +05:30
const panel = document.querySelector('#js-general-settings');
2018-03-27 19:54:05 +05:30
// Our test environment automatically expands everything so we need to clear that out first
2018-12-13 13:39:08 +05:30
panel.classList.remove('expanded');
2018-03-27 19:54:05 +05:30
2018-12-13 13:39:08 +05:30
expect(panel.classList.contains('expanded')).toBe(false);
2018-03-27 19:54:05 +05:30
initSettingsPanels();
2018-12-13 13:39:08 +05:30
expect(panel.classList.contains('expanded')).toBe(true);
2018-03-27 19:54:05 +05:30
});
});
2018-12-13 13:39:08 +05:30
it('does not change the text content of triggers', () => {
const panel = document.querySelector('#js-general-settings');
const trigger = panel.querySelector('.js-settings-toggle-trigger-only');
const originalText = trigger.textContent;
initSettingsPanels();
expect(panel.classList.contains('expanded')).toBe(true);
$(trigger).click();
expect(panel.classList.contains('expanded')).toBe(false);
expect(trigger.textContent).toEqual(originalText);
});
2018-03-27 19:54:05 +05:30
});