Commit 62972975 authored by Mauricio Gonzalez's avatar Mauricio Gonzalez Committed by Paul Slaughter

Fix js test

parent 4eca9329
...@@ -35,7 +35,6 @@ import GlFieldErrors from './gl_field_errors'; ...@@ -35,7 +35,6 @@ import GlFieldErrors from './gl_field_errors';
import initUserPopovers from './user_popovers'; import initUserPopovers from './user_popovers';
import initBroadcastNotifications from './broadcast_notification'; import initBroadcastNotifications from './broadcast_notification';
import { initTopNav } from './nav'; import { initTopNav } from './nav';
import navEventHub, { EVENT_RESPONSIVE_TOGGLE } from './nav/event_hub';
import 'ee_else_ce/main_ee'; import 'ee_else_ce/main_ee';
......
...@@ -3,7 +3,6 @@ import ResponsiveApp from '~/nav/components/responsive_app.vue'; ...@@ -3,7 +3,6 @@ import ResponsiveApp from '~/nav/components/responsive_app.vue';
import ResponsiveHeader from '~/nav/components/responsive_header.vue'; import ResponsiveHeader from '~/nav/components/responsive_header.vue';
import ResponsiveHome from '~/nav/components/responsive_home.vue'; import ResponsiveHome from '~/nav/components/responsive_home.vue';
import TopNavContainerView from '~/nav/components/top_nav_container_view.vue'; import TopNavContainerView from '~/nav/components/top_nav_container_view.vue';
import eventHub, { EVENT_RESPONSIVE_TOGGLE } from '~/nav/event_hub';
import { resetMenuItemsActive } from '~/nav/utils/reset_menu_items_active'; import { resetMenuItemsActive } from '~/nav/utils/reset_menu_items_active';
import KeepAliveSlots from '~/vue_shared/components/keep_alive_slots.vue'; import KeepAliveSlots from '~/vue_shared/components/keep_alive_slots.vue';
import { TEST_NAV_DATA } from '../mock_data'; import { TEST_NAV_DATA } from '../mock_data';
...@@ -26,8 +25,7 @@ describe('~/nav/components/responsive_app.vue', () => { ...@@ -26,8 +25,7 @@ describe('~/nav/components/responsive_app.vue', () => {
}, },
}); });
}; };
const triggerResponsiveToggle = () => eventHub.$emit(EVENT_RESPONSIVE_TOGGLE); const triggerResponsiveToggle = () => document.body.classList.toggle('top-nav-responsive-open');
const findHome = () => wrapper.findComponent(ResponsiveHome); const findHome = () => wrapper.findComponent(ResponsiveHome);
const findMobileOverlay = () => wrapper.find('[data-testid="mobile-overlay"]'); const findMobileOverlay = () => wrapper.find('[data-testid="mobile-overlay"]');
const findSubviewHeader = () => wrapper.findComponent(ResponsiveHeader); const findSubviewHeader = () => wrapper.findComponent(ResponsiveHeader);
...@@ -68,7 +66,8 @@ describe('~/nav/components/responsive_app.vue', () => { ...@@ -68,7 +66,8 @@ describe('~/nav/components/responsive_app.vue', () => {
({ bodyHtml, expectation }) => { ({ bodyHtml, expectation }) => {
document.body.innerHTML = bodyHtml; document.body.innerHTML = bodyHtml;
triggerResponsiveToggle(); if (bodyHtml === HTML_HEADER_WITH_MENU_EXPANDED)
triggerResponsiveToggle();
expect(hasBodyResponsiveOpen()).toBe(expectation); expect(hasBodyResponsiveOpen()).toBe(expectation);
}, },
...@@ -99,6 +98,7 @@ describe('~/nav/components/responsive_app.vue', () => { ...@@ -99,6 +98,7 @@ describe('~/nav/components/responsive_app.vue', () => {
describe('with menu expanded in body', () => { describe('with menu expanded in body', () => {
beforeEach(() => { beforeEach(() => {
document.body.innerHTML = HTML_HEADER_WITH_MENU_EXPANDED; document.body.innerHTML = HTML_HEADER_WITH_MENU_EXPANDED;
triggerResponsiveToggle();
createComponent(); createComponent();
}); });
...@@ -167,8 +167,6 @@ describe('~/nav/components/responsive_app.vue', () => { ...@@ -167,8 +167,6 @@ describe('~/nav/components/responsive_app.vue', () => {
}); });
it('responsive toggle event does nothing', () => { it('responsive toggle event does nothing', () => {
triggerResponsiveToggle();
expect(hasBodyResponsiveOpen()).toBe(false); expect(hasBodyResponsiveOpen()).toBe(false);
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment