blob: 1ef91181e1ded7eac090465970503c7a1b3e0ea1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
import $ from 'jquery';
import htmlGroupsEdit from 'test_fixtures/groups/edit.html';
import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures';
import initSettingsPanels, { isExpanded } from '~/settings_panels';
describe('Settings Panels', () => {
beforeEach(() => {
setHTMLFixture(htmlGroupsEdit);
});
afterEach(() => {
resetHTMLFixture();
});
describe('initSettingsPane', () => {
afterEach(() => {
window.location.hash = '';
});
it('should expand linked hash fragment panel', () => {
window.location.hash = '#js-general-settings';
const panel = document.querySelector('#js-general-settings');
// Our test environment automatically expands everything so we need to clear that out first
panel.classList.remove('expanded');
expect(isExpanded(panel)).toBe(false);
initSettingsPanels();
expect(isExpanded(panel)).toBe(true);
});
it('should expand panel containing linked hash', () => {
window.location.hash = '#group_description';
const panel = document.querySelector('#js-general-settings');
// Our test environment automatically expands everything so we need to clear that out first
panel.classList.remove('expanded');
expect(isExpanded(panel)).toBe(false);
initSettingsPanels();
expect(isExpanded(panel)).toBe(true);
});
});
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(isExpanded(panel)).toBe(true);
$(trigger).click();
expect(isExpanded(panel)).toBe(false);
expect(trigger.textContent).toEqual(originalText);
});
});
|