blob: ab9620467349a989705620f4336e157eb52bd9d0 [file] [log] [blame]
Derick Montaguead2ceb62020-04-24 18:11:04 -05001import { mount, createWrapper } from '@vue/test-utils';
Sukanya Pandey98059c92020-03-26 17:10:32 +05302import AppNavigation from '@/components/AppNavigation';
3import Vue from 'vue';
4import { BootstrapVue } from 'bootstrap-vue';
5
6describe('AppNavigation.vue', () => {
7 let wrapper;
8 Vue.use(BootstrapVue);
9
10 wrapper = mount(AppNavigation, {
11 mocks: {
Derick Montague602e98a2020-10-21 16:20:00 -050012 $t: (key) => key,
13 },
Sukanya Pandey98059c92020-03-26 17:10:32 +053014 });
15
Derick Montaguead2ceb62020-04-24 18:11:04 -050016 it('should exist', async () => {
17 expect(wrapper.exists()).toBe(true);
Sukanya Pandey98059c92020-03-26 17:10:32 +053018 });
19
Derick Montaguead2ceb62020-04-24 18:11:04 -050020 it('should render correctly', () => {
21 expect(wrapper.element).toMatchSnapshot();
22 });
Sukanya Pandey98059c92020-03-26 17:10:32 +053023
Derick Montaguead2ceb62020-04-24 18:11:04 -050024 it('should render with nav-container open', () => {
25 wrapper.vm.isNavigationOpen = true;
26 expect(wrapper.element).toMatchSnapshot();
27 });
28
Sukanya Pandeyedb8a772020-10-29 11:33:42 +053029 it('Nav Overlay click should emit change-is-navigation-open event', async () => {
Derick Montaguead2ceb62020-04-24 18:11:04 -050030 const rootWrapper = createWrapper(wrapper.vm.$root);
31 const navOverlay = wrapper.find('#nav-overlay');
32 navOverlay.trigger('click');
33 await wrapper.vm.$nextTick();
Sukanya Pandeyedb8a772020-10-29 11:33:42 +053034 expect(rootWrapper.emitted('change-is-navigation-open')).toBeTruthy();
Derick Montaguead2ceb62020-04-24 18:11:04 -050035 });
36
Sukanya Pandeyedb8a772020-10-29 11:33:42 +053037 it('toggle-navigation event should toggle isNavigation data prop value', async () => {
Derick Montaguead2ceb62020-04-24 18:11:04 -050038 const rootWrapper = createWrapper(wrapper.vm.$root);
39 wrapper.vm.isNavigationOpen = false;
Sukanya Pandeyedb8a772020-10-29 11:33:42 +053040 rootWrapper.vm.$emit('toggle-navigation');
Derick Montaguead2ceb62020-04-24 18:11:04 -050041 expect(wrapper.vm.isNavigationOpen).toBe(true);
Sukanya Pandeyedb8a772020-10-29 11:33:42 +053042 rootWrapper.vm.$emit('toggle-navigation');
Derick Montaguead2ceb62020-04-24 18:11:04 -050043 expect(wrapper.vm.isNavigationOpen).toBe(false);
Sukanya Pandey98059c92020-03-26 17:10:32 +053044 });
45});