|
|
|
@ -356,18 +356,13 @@ describe('Core base tests', function() { |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
describe('Main menu mobile toggle', function() { |
|
|
|
|
var oldMatchMedia; |
|
|
|
|
var clock; |
|
|
|
|
var $toggle; |
|
|
|
|
var $navigation; |
|
|
|
|
var clock; |
|
|
|
|
|
|
|
|
|
beforeEach(function() { |
|
|
|
|
clock = sinon.useFakeTimers(); |
|
|
|
|
oldMatchMedia = OC._matchMedia; |
|
|
|
|
// a separate method was needed because window.matchMedia
|
|
|
|
|
// cannot be stubbed due to a bug in PhantomJS:
|
|
|
|
|
// https://github.com/ariya/phantomjs/issues/12069
|
|
|
|
|
OC._matchMedia = sinon.stub(); |
|
|
|
|
$('#testArea').append('<div id="header">' + |
|
|
|
|
'<a id="owncloud" href="#"></a>' + |
|
|
|
|
'</div>' + |
|
|
|
@ -375,43 +370,15 @@ describe('Core base tests', function() { |
|
|
|
|
$toggle = $('#owncloud'); |
|
|
|
|
$navigation = $('#navigation'); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
afterEach(function() { |
|
|
|
|
OC._matchMedia = oldMatchMedia; |
|
|
|
|
clock.restore(); |
|
|
|
|
}); |
|
|
|
|
it('Sets up menu toggle in mobile mode', function() { |
|
|
|
|
OC._matchMedia.returns({matches: true}); |
|
|
|
|
it('Sets up menu toggle', function() { |
|
|
|
|
window.initCore(); |
|
|
|
|
expect($toggle.hasClass('menutoggle')).toEqual(true); |
|
|
|
|
expect($navigation.hasClass('menu')).toEqual(true); |
|
|
|
|
}); |
|
|
|
|
it('Does not set up menu toggle in desktop mode', function() { |
|
|
|
|
OC._matchMedia.returns({matches: false}); |
|
|
|
|
window.initCore(); |
|
|
|
|
expect($toggle.hasClass('menutoggle')).toEqual(false); |
|
|
|
|
expect($navigation.hasClass('menu')).toEqual(false); |
|
|
|
|
}); |
|
|
|
|
it('Switches on menu toggle when mobile mode changes', function() { |
|
|
|
|
var mq = {matches: false}; |
|
|
|
|
OC._matchMedia.returns(mq); |
|
|
|
|
window.initCore(); |
|
|
|
|
expect($toggle.hasClass('menutoggle')).toEqual(false); |
|
|
|
|
mq.matches = true; |
|
|
|
|
$(window).trigger('resize'); |
|
|
|
|
expect($toggle.hasClass('menutoggle')).toEqual(true); |
|
|
|
|
}); |
|
|
|
|
it('Switches off menu toggle when mobile mode changes', function() { |
|
|
|
|
var mq = {matches: true}; |
|
|
|
|
OC._matchMedia.returns(mq); |
|
|
|
|
window.initCore(); |
|
|
|
|
expect($toggle.hasClass('menutoggle')).toEqual(true); |
|
|
|
|
mq.matches = false; |
|
|
|
|
$(window).trigger('resize'); |
|
|
|
|
expect($toggle.hasClass('menutoggle')).toEqual(false); |
|
|
|
|
}); |
|
|
|
|
it('Clicking menu toggle toggles navigation in mobile mode', function() { |
|
|
|
|
OC._matchMedia.returns({matches: true}); |
|
|
|
|
it('Clicking menu toggle toggles navigation in', function() { |
|
|
|
|
window.initCore(); |
|
|
|
|
$navigation.hide(); // normally done through media query triggered CSS
|
|
|
|
|
expect($navigation.is(':visible')).toEqual(false); |
|
|
|
@ -422,49 +389,6 @@ describe('Core base tests', function() { |
|
|
|
|
clock.tick(1 * 1000); |
|
|
|
|
expect($navigation.is(':visible')).toEqual(false); |
|
|
|
|
}); |
|
|
|
|
it('Clicking menu toggle does not toggle navigation in desktop mode', function() { |
|
|
|
|
OC._matchMedia.returns({matches: false}); |
|
|
|
|
window.initCore(); |
|
|
|
|
expect($navigation.is(':visible')).toEqual(true); |
|
|
|
|
$toggle.click(); |
|
|
|
|
expect($navigation.is(':visible')).toEqual(true); |
|
|
|
|
}); |
|
|
|
|
it('Switching to mobile mode hides navigation', function() { |
|
|
|
|
var mq = {matches: false}; |
|
|
|
|
OC._matchMedia.returns(mq); |
|
|
|
|
window.initCore(); |
|
|
|
|
expect($navigation.is(':visible')).toEqual(true); |
|
|
|
|
mq.matches = true; |
|
|
|
|
$(window).trigger('resize'); |
|
|
|
|
expect($navigation.is(':visible')).toEqual(false); |
|
|
|
|
}); |
|
|
|
|
it('Switching to desktop mode shows navigation', function() { |
|
|
|
|
var mq = {matches: true}; |
|
|
|
|
OC._matchMedia.returns(mq); |
|
|
|
|
window.initCore(); |
|
|
|
|
expect($navigation.is(':visible')).toEqual(false); |
|
|
|
|
mq.matches = false; |
|
|
|
|
$(window).trigger('resize'); |
|
|
|
|
expect($navigation.is(':visible')).toEqual(true); |
|
|
|
|
}); |
|
|
|
|
it('Switch to desktop with opened menu then back to mobile resets toggle', function() { |
|
|
|
|
var mq = {matches: true}; |
|
|
|
|
OC._matchMedia.returns(mq); |
|
|
|
|
window.initCore(); |
|
|
|
|
expect($navigation.is(':visible')).toEqual(false); |
|
|
|
|
$toggle.click(); |
|
|
|
|
clock.tick(1 * 1000); |
|
|
|
|
expect($navigation.is(':visible')).toEqual(true); |
|
|
|
|
mq.matches = false; |
|
|
|
|
$(window).trigger('resize'); |
|
|
|
|
expect($navigation.is(':visible')).toEqual(true); |
|
|
|
|
mq.matches = true; |
|
|
|
|
$(window).trigger('resize'); |
|
|
|
|
expect($navigation.is(':visible')).toEqual(false); |
|
|
|
|
$toggle.click(); |
|
|
|
|
clock.tick(1 * 1000); |
|
|
|
|
expect($navigation.is(':visible')).toEqual(true); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
describe('SVG extension replacement', function() { |
|
|
|
|
var svgSupportStub; |
|
|
|
|