summaryrefslogtreecommitdiff
path: root/tests/unit/Global/Search.spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/Global/Search.spec.js')
-rw-r--r--tests/unit/Global/Search.spec.js30
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();
+ });
+});