1ad2ceb6dSDerick Montagueimport { mount, createWrapper } from '@vue/test-utils'; 298059c92SSukanya Pandeyimport AppNavigation from '@/components/AppNavigation'; 398059c92SSukanya Pandeyimport Vue from 'vue'; 4*fba4d625SSukanya Pandeyimport VueRouter from 'vue-router'; 598059c92SSukanya Pandeyimport { BootstrapVue } from 'bootstrap-vue'; 698059c92SSukanya Pandey 798059c92SSukanya Pandeydescribe('AppNavigation.vue', () => { 898059c92SSukanya Pandey let wrapper; 998059c92SSukanya Pandey Vue.use(BootstrapVue); 10*fba4d625SSukanya Pandey Vue.use(VueRouter); 11*fba4d625SSukanya Pandey const router = new VueRouter(); 1298059c92SSukanya Pandey 1398059c92SSukanya Pandey wrapper = mount(AppNavigation, { 14*fba4d625SSukanya Pandey router, 1598059c92SSukanya Pandey mocks: { 16602e98aaSDerick Montague $t: (key) => key, 17602e98aaSDerick Montague }, 1898059c92SSukanya Pandey }); 1998059c92SSukanya Pandey 20ad2ceb6dSDerick Montague it('should exist', async () => { 21ad2ceb6dSDerick Montague expect(wrapper.exists()).toBe(true); 2298059c92SSukanya Pandey }); 2398059c92SSukanya Pandey 24ad2ceb6dSDerick Montague it('should render correctly', () => { 25ad2ceb6dSDerick Montague expect(wrapper.element).toMatchSnapshot(); 26ad2ceb6dSDerick Montague }); 27ad2ceb6dSDerick Montague 28ad2ceb6dSDerick Montague it('should render with nav-container open', () => { 2998059c92SSukanya Pandey wrapper.vm.isNavigationOpen = true; 30ad2ceb6dSDerick Montague expect(wrapper.element).toMatchSnapshot(); 3198059c92SSukanya Pandey }); 3298059c92SSukanya Pandey 33edb8a774SSukanya Pandey it('Nav Overlay click should emit change-is-navigation-open event', async () => { 34ad2ceb6dSDerick Montague const rootWrapper = createWrapper(wrapper.vm.$root); 35ad2ceb6dSDerick Montague const navOverlay = wrapper.find('#nav-overlay'); 36ad2ceb6dSDerick Montague navOverlay.trigger('click'); 37ad2ceb6dSDerick Montague await wrapper.vm.$nextTick(); 38edb8a774SSukanya Pandey expect(rootWrapper.emitted('change-is-navigation-open')).toBeTruthy(); 39ad2ceb6dSDerick Montague }); 40ad2ceb6dSDerick Montague 41edb8a774SSukanya Pandey it('toggle-navigation event should toggle isNavigation data prop value', async () => { 42ad2ceb6dSDerick Montague const rootWrapper = createWrapper(wrapper.vm.$root); 4398059c92SSukanya Pandey wrapper.vm.isNavigationOpen = false; 44edb8a774SSukanya Pandey rootWrapper.vm.$emit('toggle-navigation'); 45ad2ceb6dSDerick Montague expect(wrapper.vm.isNavigationOpen).toBe(true); 46edb8a774SSukanya Pandey rootWrapper.vm.$emit('toggle-navigation'); 47ad2ceb6dSDerick Montague expect(wrapper.vm.isNavigationOpen).toBe(false); 4898059c92SSukanya Pandey }); 4998059c92SSukanya Pandey}); 50