diff options
Diffstat (limited to 'spec/frontend/search_settings/index_spec.js')
-rw-r--r-- | spec/frontend/search_settings/index_spec.js | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/spec/frontend/search_settings/index_spec.js b/spec/frontend/search_settings/index_spec.js index 122ee1251bb..1d56d054eea 100644 --- a/spec/frontend/search_settings/index_spec.js +++ b/spec/frontend/search_settings/index_spec.js @@ -1,36 +1,25 @@ -import $ from 'jquery'; -import { setHTMLFixture } from 'helpers/fixtures'; +import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures'; import initSearch from '~/search_settings'; -import { expandSection, closeSection } from '~/settings_panels'; +import mount from '~/search_settings/mount'; -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 }); - }); +jest.mock('~/search_settings/mount'); +describe('~/search_settings', () => { afterEach(() => { - app.$destroy(); + resetHTMLFixture(); }); - it('calls settings_panel.onExpand when expand event is emitted', () => { - const section = { name: 'section' }; - app.$refs.searchSettings.$emit('expand', section); + it('initializes search settings when js-search-settings-app is available', async () => { + setHTMLFixture('<div class="js-search-settings-app"></div>'); + + await initSearch(); - expect(expandSection).toHaveBeenCalledWith($(section)); + expect(mount).toHaveBeenCalled(); }); - it('calls settings_panel.closeSection when collapse event is emitted', () => { - const section = { name: 'section' }; - app.$refs.searchSettings.$emit('collapse', section); + it('does not initialize search settings when js-search-settings-app is unavailable', async () => { + await initSearch(); - expect(closeSection).toHaveBeenCalledWith($(section)); + expect(mount).not.toHaveBeenCalled(); }); }); |