blob: 58eaae9108e64ce60c2a43fa344535c6d720419f [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: {
12 $t: key => key
13 }
14 });
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
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 Pandey98059c92020-03-26 17:10:32 +053044 });
45});