2018-12-13 13:39:08 +05:30
|
|
|
import $ from 'jquery';
|
2021-03-11 19:13:27 +05:30
|
|
|
import initSettingsPanels, { isExpanded } from '~/settings_panels';
|
2018-03-27 19:54:05 +05:30
|
|
|
|
|
|
|
describe('Settings Panels', () => {
|
|
|
|
beforeEach(() => {
|
2019-07-07 11:18:12 +05:30
|
|
|
loadFixtures('groups/edit.html');
|
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
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
expect(isExpanded(panel)).toBe(false);
|
2018-03-27 19:54:05 +05:30
|
|
|
|
|
|
|
initSettingsPanels();
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
expect(isExpanded(panel)).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();
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
expect(isExpanded(panel)).toBe(true);
|
2018-12-13 13:39:08 +05:30
|
|
|
|
|
|
|
$(trigger).click();
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
expect(isExpanded(panel)).toBe(false);
|
2018-12-13 13:39:08 +05:30
|
|
|
expect(trigger.textContent).toEqual(originalText);
|
|
|
|
});
|
2018-03-27 19:54:05 +05:30
|
|
|
});
|