Derick Montague | ad2ceb6 | 2020-04-24 18:11:04 -0500 | [diff] [blame] | 1 | import { mount, createWrapper } from '@vue/test-utils'; |
Sukanya Pandey | 98059c9 | 2020-03-26 17:10:32 +0530 | [diff] [blame] | 2 | import AppNavigation from '@/components/AppNavigation'; |
| 3 | import Vue from 'vue'; |
| 4 | import { BootstrapVue } from 'bootstrap-vue'; |
| 5 | |
| 6 | describe('AppNavigation.vue', () => { |
| 7 | let wrapper; |
| 8 | Vue.use(BootstrapVue); |
| 9 | |
| 10 | wrapper = mount(AppNavigation, { |
| 11 | mocks: { |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 12 | $t: (key) => key, |
| 13 | }, |
Sukanya Pandey | 98059c9 | 2020-03-26 17:10:32 +0530 | [diff] [blame] | 14 | }); |
| 15 | |
Derick Montague | ad2ceb6 | 2020-04-24 18:11:04 -0500 | [diff] [blame] | 16 | it('should exist', async () => { |
| 17 | expect(wrapper.exists()).toBe(true); |
Sukanya Pandey | 98059c9 | 2020-03-26 17:10:32 +0530 | [diff] [blame] | 18 | }); |
| 19 | |
Derick Montague | ad2ceb6 | 2020-04-24 18:11:04 -0500 | [diff] [blame] | 20 | it('should render correctly', () => { |
| 21 | expect(wrapper.element).toMatchSnapshot(); |
| 22 | }); |
Sukanya Pandey | 98059c9 | 2020-03-26 17:10:32 +0530 | [diff] [blame] | 23 | |
Derick Montague | ad2ceb6 | 2020-04-24 18:11:04 -0500 | [diff] [blame] | 24 | it('should render with nav-container open', () => { |
| 25 | wrapper.vm.isNavigationOpen = true; |
| 26 | expect(wrapper.element).toMatchSnapshot(); |
| 27 | }); |
| 28 | |
Sukanya Pandey | edb8a77 | 2020-10-29 11:33:42 +0530 | [diff] [blame^] | 29 | it('Nav Overlay click should emit change-is-navigation-open event', async () => { |
Derick Montague | ad2ceb6 | 2020-04-24 18:11:04 -0500 | [diff] [blame] | 30 | const rootWrapper = createWrapper(wrapper.vm.$root); |
| 31 | const navOverlay = wrapper.find('#nav-overlay'); |
| 32 | navOverlay.trigger('click'); |
| 33 | await wrapper.vm.$nextTick(); |
Sukanya Pandey | edb8a77 | 2020-10-29 11:33:42 +0530 | [diff] [blame^] | 34 | expect(rootWrapper.emitted('change-is-navigation-open')).toBeTruthy(); |
Derick Montague | ad2ceb6 | 2020-04-24 18:11:04 -0500 | [diff] [blame] | 35 | }); |
| 36 | |
Sukanya Pandey | edb8a77 | 2020-10-29 11:33:42 +0530 | [diff] [blame^] | 37 | it('toggle-navigation event should toggle isNavigation data prop value', async () => { |
Derick Montague | ad2ceb6 | 2020-04-24 18:11:04 -0500 | [diff] [blame] | 38 | const rootWrapper = createWrapper(wrapper.vm.$root); |
| 39 | wrapper.vm.isNavigationOpen = false; |
Sukanya Pandey | edb8a77 | 2020-10-29 11:33:42 +0530 | [diff] [blame^] | 40 | rootWrapper.vm.$emit('toggle-navigation'); |
Derick Montague | ad2ceb6 | 2020-04-24 18:11:04 -0500 | [diff] [blame] | 41 | expect(wrapper.vm.isNavigationOpen).toBe(true); |
Sukanya Pandey | edb8a77 | 2020-10-29 11:33:42 +0530 | [diff] [blame^] | 42 | rootWrapper.vm.$emit('toggle-navigation'); |
Derick Montague | ad2ceb6 | 2020-04-24 18:11:04 -0500 | [diff] [blame] | 43 | expect(wrapper.vm.isNavigationOpen).toBe(false); |
Sukanya Pandey | 98059c9 | 2020-03-26 17:10:32 +0530 | [diff] [blame] | 44 | }); |
| 45 | }); |