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