summaryrefslogtreecommitdiff
path: root/spec/javascripts/settings_panels_spec.js
blob: 2c5d91a45bc1bb60668f4d82f85c958f11077219 (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
import $ from 'jquery';
import initSettingsPanels from '~/settings_panels';

describe('Settings Panels', () => {
  preloadFixtures('groups/edit.html');

  beforeEach(() => {
    loadFixtures('groups/edit.html');
  });

  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(panel.classList.contains('expanded')).toBe(false);

      initSettingsPanels();

      expect(panel.classList.contains('expanded')).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(panel.classList.contains('expanded')).toBe(true);

    $(trigger).click();

    expect(panel.classList.contains('expanded')).toBe(false);
    expect(trigger.textContent).toEqual(originalText);
  });
});