1import { mount, createLocalVue } from '@vue/test-utils';
2import Search from '@/components/Global/Search';
3import BootstrapVue from 'bootstrap-vue';
4
5const localVue = createLocalVue();
6localVue.use(BootstrapVue);
7
8describe('Search.vue', () => {
9  const wrapper = mount(Search, {
10    localVue,
11    mocks: {
12      $t: (key) => key,
13    },
14  });
15  it('should exist', () => {
16    expect(wrapper.exists()).toBe(true);
17  });
18  it('should emit change-search on triggering onChangeInput', () => {
19    wrapper.find('input').trigger('input');
20    expect(wrapper.emitted('change-search')).toHaveLength(1);
21  });
22  it('should emit clear-search on triggering onClearSearch', async () => {
23    await wrapper.setData({ filter: 'true' });
24    wrapper.find('button').trigger('click');
25    expect(wrapper.emitted('clear-search')).toHaveLength(1);
26  });
27  it('should render correctly', () => {
28    expect(wrapper.element).toMatchSnapshot();
29  });
30});
31