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: { |
| 12 | $t: key => key |
| 13 | } |
| 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 | |
| 29 | it('Nav Overlay cliick should emit change:isNavigationOpen event', async () => { |
| 30 | const rootWrapper = createWrapper(wrapper.vm.$root); |
| 31 | const navOverlay = wrapper.find('#nav-overlay'); |
| 32 | navOverlay.trigger('click'); |
| 33 | await wrapper.vm.$nextTick(); |
| 34 | expect(rootWrapper.emitted('change:isNavigationOpen')).toBeTruthy(); |
| 35 | }); |
| 36 | |
| 37 | it('toggle:navigation event should toggle isNavigation data prop value', async () => { |
| 38 | const rootWrapper = createWrapper(wrapper.vm.$root); |
| 39 | wrapper.vm.isNavigationOpen = false; |
| 40 | rootWrapper.vm.$emit('toggle:navigation'); |
| 41 | expect(wrapper.vm.isNavigationOpen).toBe(true); |
| 42 | rootWrapper.vm.$emit('toggle:navigation'); |
| 43 | expect(wrapper.vm.isNavigationOpen).toBe(false); |
Sukanya Pandey | 98059c9 | 2020-03-26 17:10:32 +0530 | [diff] [blame] | 44 | }); |
| 45 | }); |