2018-10-15 09:36:19 -04:00
|
|
|
import $ from 'jquery';
|
2018-02-12 20:30:03 -05:00
|
|
|
import initSettingsPanels from '~/settings_panels';
|
|
|
|
|
|
|
|
describe('Settings Panels', () => {
|
2018-10-15 09:36:19 -04:00
|
|
|
preloadFixtures('groups/edit.html.raw');
|
2018-02-12 20:30:03 -05:00
|
|
|
|
|
|
|
beforeEach(() => {
|
2018-10-15 09:36:19 -04:00
|
|
|
loadFixtures('groups/edit.html.raw');
|
2018-02-12 20:30:03 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('initSettingsPane', () => {
|
|
|
|
afterEach(() => {
|
2018-06-15 11:58:27 -04:00
|
|
|
window.location.hash = '';
|
2018-02-12 20:30:03 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should expand linked hash fragment panel', () => {
|
2018-10-15 09:36:19 -04:00
|
|
|
window.location.hash = '#js-general-settings';
|
2018-02-12 20:30:03 -05:00
|
|
|
|
2018-10-15 09:36:19 -04:00
|
|
|
const panel = document.querySelector('#js-general-settings');
|
2018-02-12 20:30:03 -05:00
|
|
|
// Our test environment automatically expands everything so we need to clear that out first
|
2018-10-15 09:36:19 -04:00
|
|
|
panel.classList.remove('expanded');
|
2018-02-12 20:30:03 -05:00
|
|
|
|
2018-10-15 09:36:19 -04:00
|
|
|
expect(panel.classList.contains('expanded')).toBe(false);
|
2018-02-12 20:30:03 -05:00
|
|
|
|
|
|
|
initSettingsPanels();
|
|
|
|
|
2018-10-15 09:36:19 -04:00
|
|
|
expect(panel.classList.contains('expanded')).toBe(true);
|
2018-02-12 20:30:03 -05:00
|
|
|
});
|
|
|
|
});
|
2018-10-15 09:36:19 -04:00
|
|
|
|
|
|
|
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-02-12 20:30:03 -05:00
|
|
|
});
|