Ed Tanous | 7d6b44c | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 1 | import { mount } from '@vue/test-utils'; |
Sukanya Pandey | 5ecdd66 | 2021-01-05 12:07:36 +0530 | [diff] [blame] | 2 | import Search from '@/components/Global/Search'; |
Sukanya Pandey | 5ecdd66 | 2021-01-05 12:07:36 +0530 | [diff] [blame] | 3 | |
| 4 | describe('Search.vue', () => { |
| 5 | const wrapper = mount(Search, { |
Sukanya Pandey | 5ecdd66 | 2021-01-05 12:07:36 +0530 | [diff] [blame] | 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 | }); |