#10: Let keys accept arrays of keys
[deck.js.git] / test / spec.menu.js
blob79e3848599aef84788e1254e0e1cc518afeba60c
1 describe('Deck JS Menu', function() {
2         var $d = $(document);
3         
4         beforeEach(function() {
5                 loadFixtures('standard.html');
6                 if (Modernizr.history) {
7                         history.replaceState({}, "", "#")
8                 }
9                 else {
10                         window.location.hash = '#';
11                 }
12                 $.deck('.slide');
13         });
14         
15         describe('showMenu()', function() {
16                 it('should show the menu', function() {
17                         expect($(defaults.selectors.container)).not.toHaveClass(defaults.classes.menu);
18                         $.deck('showMenu');
19                         expect($(defaults.selectors.container)).toHaveClass(defaults.classes.menu);
20                 });
21         });
22         
23         describe('hideMenu()', function() {
24                 it('should hide the menu', function() {
25                         $.deck('showMenu');
26                         $.deck('hideMenu');
27                         expect($(defaults.selectors.container)).not.toHaveClass(defaults.classes.menu);
28                 });
29         });
30         
31         describe('toggleMenu()', function() {
32                 it('should toggle menu on and off', function() {
33                         expect($(defaults.selectors.container)).not.toHaveClass(defaults.classes.menu);
34                         $.deck('toggleMenu');
35                         expect($(defaults.selectors.container)).toHaveClass(defaults.classes.menu);
36                         $.deck('toggleMenu');
37                         expect($(defaults.selectors.container)).not.toHaveClass(defaults.classes.menu);
38                 });
39         });
40         
41         describe('key bindings', function() {
42                 var e;
44                 beforeEach(function() {
45                         e = jQuery.Event('keydown.deckmenu');
46                 });
47                 
48                 it('should toggle the menu if the specified key is pressed', function() {
49                         e.which = 77; // m
50                         $d.trigger(e);
51                         expect($(defaults.selectors.container)).toHaveClass(defaults.classes.menu);
52                         $d.trigger(e);
53                         expect($(defaults.selectors.container)).not.toHaveClass(defaults.classes.menu);
54                 });
55         });
56 });