diff options
author | Sukanya Pandey <sukapan1@in.ibm.com> | 2021-01-05 09:37:36 +0300 |
---|---|---|
committer | Derick Montague <derick.montague@ibm.com> | 2021-01-20 21:05:11 +0300 |
commit | 5ecdd6663904f4730c06a47efedbd382094e03c3 (patch) | |
tree | 7f4f52241a3525a0cc07f2ed451ea3035d064c78 /tests/unit/Global/Search.spec.js | |
parent | a87f3e75a6a66937fd27047c0065a9aa9846abee (diff) | |
download | webui-vue-5ecdd6663904f4730c06a47efedbd382094e03c3.tar.xz |
Add unit test cases for search component
Signed-off-by: Sukanya Pandey <sukapan1@in.ibm.com>
Change-Id: I9721a9bc8b1fce850b824a2f9d7a6d199c5e0236
Diffstat (limited to 'tests/unit/Global/Search.spec.js')
-rw-r--r-- | tests/unit/Global/Search.spec.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/unit/Global/Search.spec.js b/tests/unit/Global/Search.spec.js new file mode 100644 index 00000000..eb553df6 --- /dev/null +++ b/tests/unit/Global/Search.spec.js @@ -0,0 +1,30 @@ +import { mount, createLocalVue } from '@vue/test-utils'; +import Search from '@/components/Global/Search'; +import BootstrapVue from 'bootstrap-vue'; + +const localVue = createLocalVue(); +localVue.use(BootstrapVue); + +describe('Search.vue', () => { + const wrapper = mount(Search, { + localVue, + mocks: { + $t: (key) => key, + }, + }); + it('should exist', () => { + expect(wrapper.exists()).toBe(true); + }); + it('should emit change-search on triggering onChangeInput', () => { + wrapper.find('input').trigger('input'); + expect(wrapper.emitted('change-search')).toHaveLength(1); + }); + it('should emit clear-search on triggering onClearSearch', async () => { + await wrapper.setData({ filter: 'true' }); + wrapper.find('button').trigger('click'); + expect(wrapper.emitted('clear-search')).toHaveLength(1); + }); + it('should render correctly', () => { + expect(wrapper.element).toMatchSnapshot(); + }); +}); |