summaryrefslogtreecommitdiff
path: root/spec/frontend/search_settings/index_spec.js
blob: 122ee1251bb58dd26cedc604b175b77ce0cf2c65 (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
import $ from 'jquery';
import { setHTMLFixture } from 'helpers/fixtures';
import initSearch from '~/search_settings';
import { expandSection, closeSection } from '~/settings_panels';

jest.mock('~/settings_panels');

describe('search_settings/index', () => {
  let app;

  beforeEach(() => {
    const el = document.createElement('div');

    setHTMLFixture('<div id="content-body"></div>');

    app = initSearch({ el });
  });

  afterEach(() => {
    app.$destroy();
  });

  it('calls settings_panel.onExpand when expand event is emitted', () => {
    const section = { name: 'section' };
    app.$refs.searchSettings.$emit('expand', section);

    expect(expandSection).toHaveBeenCalledWith($(section));
  });

  it('calls settings_panel.closeSection when collapse event is emitted', () => {
    const section = { name: 'section' };
    app.$refs.searchSettings.$emit('collapse', section);

    expect(closeSection).toHaveBeenCalledWith($(section));
  });
});