Commit 8bcdc5d2 authored by Vitaly Slobodin's avatar Vitaly Slobodin

Introduce helper for mocking the sidebar HTML

parent 5a77bf53
...@@ -51,6 +51,7 @@ describe('Fly out sidebar navigation', () => { ...@@ -51,6 +51,7 @@ describe('Fly out sidebar navigation', () => {
mockBoundingClientRect(el, CONTAINER_INITIAL_BOUNDING_RECT); mockBoundingClientRect(el, CONTAINER_INITIAL_BOUNDING_RECT);
mockBoundingClientRect(subItems, SUB_ITEMS_INITIAL_BOUNDING_RECT); mockBoundingClientRect(subItems, SUB_ITEMS_INITIAL_BOUNDING_RECT);
}; };
const mockSidebarFragment = (styleProps = '') => `<div class="sidebar-sub-level-items" style="${styleProps}"></div>`
beforeEach(() => { beforeEach(() => {
el = document.createElement('div'); el = document.createElement('div');
...@@ -82,8 +83,8 @@ describe('Fly out sidebar navigation', () => { ...@@ -82,8 +83,8 @@ describe('Fly out sidebar navigation', () => {
describe('getHideSubItemsInterval', () => { describe('getHideSubItemsInterval', () => {
beforeEach(() => { beforeEach(() => {
el.innerHTML =
'<div class="sidebar-sub-level-items" style="position: fixed; top: 0; left: 100px; height: 150px;"></div>'; el.innerHTML = mockSidebarFragment('position: fixed; top: 0; left: 100px; height: 150px;');
mockBoundingRects(); mockBoundingRects();
}); });
...@@ -157,7 +158,7 @@ describe('Fly out sidebar navigation', () => { ...@@ -157,7 +158,7 @@ describe('Fly out sidebar navigation', () => {
it('removes is-over class if currentOpenMenu is null & there are sub-items', () => { it('removes is-over class if currentOpenMenu is null & there are sub-items', () => {
setOpenMenu(null); setOpenMenu(null);
el.innerHTML = '<div class="sidebar-sub-level-items" style="position: absolute;"></div>'; el.innerHTML = mockSidebarFragment('position: absolute');
mouseLeaveTopItem(el); mouseLeaveTopItem(el);
...@@ -166,7 +167,7 @@ describe('Fly out sidebar navigation', () => { ...@@ -166,7 +167,7 @@ describe('Fly out sidebar navigation', () => {
it('does not remove is-over class if currentOpenMenu is the passed in sub-items', () => { it('does not remove is-over class if currentOpenMenu is the passed in sub-items', () => {
setOpenMenu(null); setOpenMenu(null);
el.innerHTML = '<div class="sidebar-sub-level-items" style="position: absolute;"></div>'; el.innerHTML = mockSidebarFragment('position: absolute');
setOpenMenu(findSubItems()); setOpenMenu(findSubItems());
mouseLeaveTopItem(el); mouseLeaveTopItem(el);
...@@ -177,8 +178,7 @@ describe('Fly out sidebar navigation', () => { ...@@ -177,8 +178,7 @@ describe('Fly out sidebar navigation', () => {
describe('mouseEnterTopItems', () => { describe('mouseEnterTopItems', () => {
beforeEach(() => { beforeEach(() => {
el.innerHTML = el.innerHTML = mockSidebarFragment('position: absolute; top: 0; left: 100px; height: 200px;');
'<div class="sidebar-sub-level-items" style="position: absolute; top: 0; left: 100px; height: 200px;"></div>';
mockBoundingRects(); mockBoundingRects();
}); });
...@@ -221,7 +221,7 @@ describe('Fly out sidebar navigation', () => { ...@@ -221,7 +221,7 @@ describe('Fly out sidebar navigation', () => {
describe('showSubLevelItems', () => { describe('showSubLevelItems', () => {
beforeEach(() => { beforeEach(() => {
el.innerHTML = '<div class="sidebar-sub-level-items" style="position: absolute;"></div>'; el.innerHTML = mockSidebarFragment('position: absolute');
}); });
it('adds is-over class to el', () => { it('adds is-over class to el', () => {
...@@ -340,7 +340,7 @@ describe('Fly out sidebar navigation', () => { ...@@ -340,7 +340,7 @@ describe('Fly out sidebar navigation', () => {
describe('subItemsMouseLeave', () => { describe('subItemsMouseLeave', () => {
beforeEach(() => { beforeEach(() => {
el.innerHTML = '<div class="sidebar-sub-level-items" style="position: absolute;"></div>'; el.innerHTML = mockSidebarFragment('position: absolute');
setOpenMenu(findSubItems()); setOpenMenu(findSubItems());
}); });
......
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