diff options
author | 2016-11-16 17:40:01 +0200 | |
---|---|---|
committer | 2016-11-16 17:40:01 +0200 | |
commit | 11c216470c30e4c200e46e1b51d721a549f440d6 (patch) | |
tree | 03ad20c67decf7da4d52e5679c2fd22dd8f5eaa6 /doc/backends/deckjs/deck.js/test/spec.menu.js | |
parent | e46e3f598e52112b9db21d6faabde7a5c87341cb (diff) | |
parent | efba1bd2c32391c443a9dbaf0fffa6468bb681c6 (diff) |
Merge branch 'master' to rx_features phase 0.5
Signed-off-by: imarom <imarom@cisco.com>
Diffstat (limited to 'doc/backends/deckjs/deck.js/test/spec.menu.js')
-rw-r--r-- | doc/backends/deckjs/deck.js/test/spec.menu.js | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/doc/backends/deckjs/deck.js/test/spec.menu.js b/doc/backends/deckjs/deck.js/test/spec.menu.js new file mode 100644 index 00000000..3abca9fc --- /dev/null +++ b/doc/backends/deckjs/deck.js/test/spec.menu.js @@ -0,0 +1,83 @@ +describe('Deck JS Menu', function() { + var $d = $(document); + var dsc = defaults.selectors.container; + + beforeEach(function() { + loadFixtures('standard.html'); + if (Modernizr.history) { + history.replaceState({}, "", "#") + } + else { + window.location.hash = '#'; + } + $.deck('.slide'); + }); + + describe('showMenu()', function() { + it('should show the menu', function() { + expect($(dsc)).not.toHaveClass(defaults.classes.menu); + $.deck('showMenu'); + expect($(dsc)).toHaveClass(defaults.classes.menu); + }); + + it('should do nothing if menu is already showing', function() { + if (Modernizr.csstransforms) { + $.deck('showMenu'); + $.deck('showMenu'); + $.deck('hideMenu'); + expect($('.slide').attr('style')).toBeFalsy(); + } + }); + }); + + describe('hideMenu()', function() { + it('should hide the menu', function() { + $.deck('showMenu'); + $.deck('hideMenu'); + expect($(dsc)).not.toHaveClass(defaults.classes.menu); + }); + }); + + describe('toggleMenu()', function() { + it('should toggle menu on and off', function() { + expect($(dsc)).not.toHaveClass(defaults.classes.menu); + $.deck('toggleMenu'); + expect($(dsc)).toHaveClass(defaults.classes.menu); + $.deck('toggleMenu'); + expect($(dsc)).not.toHaveClass(defaults.classes.menu); + }); + }); + + describe('key bindings', function() { + var e; + + beforeEach(function() { + e = jQuery.Event('keydown.deckmenu'); + }); + + it('should toggle the menu if the specified key is pressed', function() { + e.which = 77; // m + $d.trigger(e); + expect($(dsc)).toHaveClass(defaults.classes.menu); + $d.trigger(e); + expect($(dsc)).not.toHaveClass(defaults.classes.menu); + }); + }); + + describe('touch bindings', function() { + var estart, eend; + + beforeEach(function() { + estart = jQuery.Event('touchstart.deckmenu'); + eend = jQuery.Event('touchend.deckmenu'); + }); + + it('should toggle the menu if the screen is touched', function() { + $.deck('getOptions').touch.doubletapWindow = Date.now() + 100000; + $.deck('getContainer').trigger(estart); + $.deck('getContainer').trigger(eend); + expect($(dsc)).toHaveClass(defaults.classes.menu); + }); + }); + +}); |