1import { mount, createWrapper } from '@vue/test-utils'; 2import AppNavigation from '@/components/AppNavigation'; 3import { createApp } from 'vue'; 4import Vuex from 'vuex'; 5import VueRouter from 'vue-router'; 6//import { BootstrapVue } from 'bootstrap-vue'; 7 8describe('AppNavigation.vue', () => { 9 let wrapper; 10 const router = new VueRouter(); 11 const actions = { 12 'global/userPrivilege': jest.fn(), 13 }; 14 const store = new Vuex.Store({ actions }); 15 const app = createApp(); 16 //app.use(BootstrapVue); 17 app.use(VueRouter); 18 19 wrapper = mount(AppNavigation, { 20 store, 21 router, 22 mocks: { 23 $t: (key) => key, 24 }, 25 }); 26 27 it('should exist', async () => { 28 expect(wrapper.exists()).toBe(true); 29 }); 30 31 it('should render correctly', () => { 32 expect(wrapper.element).toMatchSnapshot(); 33 }); 34 35 it('should render with nav-container open', () => { 36 wrapper.vm.isNavigationOpen = true; 37 expect(wrapper.element).toMatchSnapshot(); 38 }); 39 40 it('Nav Overlay click should emit change-is-navigation-open event', async () => { 41 const rootWrapper = createWrapper(wrapper.vm.$root); 42 const navOverlay = wrapper.find('#nav-overlay'); 43 navOverlay.trigger('click'); 44 await wrapper.vm.$nextTick(); 45 expect(rootWrapper.emitted('change-is-navigation-open')).toBeTruthy(); 46 }); 47 48 it('toggle-navigation event should toggle isNavigation data prop value', async () => { 49 const rootWrapper = createWrapper(wrapper.vm.$root); 50 wrapper.vm.isNavigationOpen = false; 51 rootWrapper.vm.$emit('toggle-navigation'); 52 expect(wrapper.vm.isNavigationOpen).toBe(true); 53 rootWrapper.vm.$emit('toggle-navigation'); 54 expect(wrapper.vm.isNavigationOpen).toBe(false); 55 }); 56}); 57