Welcome to mirror list, hosted at ThFree Co, Russian Federation.

lunr_search_spec.js « search « frontend « spec - gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 234fa7946b07b69faf2fea00feb546af64f5e6c2 (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
/**
 * @jest-environment jsdom
 */

import { shallowMount } from '@vue/test-utils';
import SearchPage from '../../../content/frontend/search/components/lunr_page.vue';

describe('content/frontend/search/components/lunr_page.vue', () => {
  it('Search form renders', () => {
    const wrapper = shallowMount(SearchPage);
    expect(wrapper.findComponent(SearchPage).isVisible()).toBe(true);
  });

  it('Index fetch failure shows an error', async () => {
    const wrapper = shallowMount(SearchPage);
    const fetch = jest.fn(() => {
      throw new Error('error');
    });

    try {
      await fetch('/assets/javascripts/lunr-index.json');
    } catch (e) {
      expect(wrapper.find('[data-testid="lunr-error"]').isVisible()).toBe(true);
    }
  });
});