Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2017-08-02 12:22:13 +0300
committerPhil Hughes <me@iamphill.com>2017-08-02 12:22:13 +0300
commit25d6a6c4b528159c288995de4909e6a8da431d0b (patch)
tree691fe780f176b93817c757b3b5658be331bf22b5 /spec/javascripts/fly_out_nav_spec.js
parente67c4a6d913ccdb4615639cb317634141da2a37b (diff)
stop mobile from showing the sub-items
Diffstat (limited to 'spec/javascripts/fly_out_nav_spec.js')
-rw-r--r--spec/javascripts/fly_out_nav_spec.js45
1 files changed, 44 insertions, 1 deletions
diff --git a/spec/javascripts/fly_out_nav_spec.js b/spec/javascripts/fly_out_nav_spec.js
index 74775911505..ab74f3e00ec 100644
--- a/spec/javascripts/fly_out_nav_spec.js
+++ b/spec/javascripts/fly_out_nav_spec.js
@@ -1,19 +1,26 @@
+/* global bp */
import {
calculateTop,
hideSubLevelItems,
showSubLevelItems,
+ canShowSubItems,
} from '~/fly_out_nav';
describe('Fly out sidebar navigation', () => {
let el;
+ let breakpointSize = 'lg';
+
beforeEach(() => {
el = document.createElement('div');
el.style.position = 'relative';
document.body.appendChild(el);
+
+ spyOn(bp, 'getBreakpointSize').and.callFake(() => breakpointSize);
});
afterEach(() => {
el.remove();
+ breakpointSize = 'lg';
});
describe('calculateTop', () => {
@@ -53,6 +60,16 @@ describe('Fly out sidebar navigation', () => {
).toBe('none');
});
+ it('does not hude subitems on mobile', () => {
+ breakpointSize = 'sm';
+
+ hideSubLevelItems(el);
+
+ expect(
+ el.querySelector('.sidebar-sub-level-items').style.display,
+ ).not.toBe('none');
+ });
+
it('removes is-over class', () => {
spyOn(el.classList, 'remove');
@@ -103,7 +120,17 @@ describe('Fly out sidebar navigation', () => {
).toHaveBeenCalledWith('is-over');
});
- it('shows sub-items', () => {
+ it('does not show sub-items on mobile', () => {
+ breakpointSize = 'sm';
+
+ showSubLevelItems(el);
+
+ expect(
+ el.querySelector('.sidebar-sub-level-items').style.display,
+ ).not.toBe('block');
+ });
+
+ it('does not shows sub-items', () => {
showSubLevelItems(el);
expect(
@@ -134,4 +161,20 @@ describe('Fly out sidebar navigation', () => {
).toHaveBeenCalledWith('is-above');
});
});
+
+ describe('canShowSubItems', () => {
+ it('returns true if on desktop size', () => {
+ expect(
+ canShowSubItems(),
+ ).toBeTruthy();
+ });
+
+ it('returns false if on mobile size', () => {
+ breakpointSize = 'sm';
+
+ expect(
+ canShowSubItems(),
+ ).toBeFalsy();
+ });
+ });
});