Sukanya Pandey | 5ecdd66 | 2021-01-05 12:07:36 +0530 | [diff] [blame] | 1 | import { mount, createLocalVue } from '@vue/test-utils'; |
| 2 | import Search from '@/components/Global/Search'; |
| 3 | import BootstrapVue from 'bootstrap-vue'; |
| 4 | |
| 5 | const localVue = createLocalVue(); |
| 6 | localVue.use(BootstrapVue); |
| 7 | |
| 8 | describe('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 | }); |