Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 'use strict'; | 1 'use strict'; |
2 | 2 |
3 describe('application hotkeys', function() { | 3 YUI(GlobalConfig).use(['juju-gui', 'juju-tests-utils', 'node-event-simulate'], |
4 var Y, app, container, windowNode; | 4 function(Y) { |
5 describe('application hotkeys', function() { | |
6 var app, container, windowNode; | |
5 | 7 |
6 before(function(done) { | 8 before(function(done) { |
7 Y = YUI(GlobalConfig).use( | |
8 ['juju-gui', 'juju-tests-utils', | |
9 'node-event-simulate'], function(Y) { | |
10 var env = { | 9 var env = { |
11 after: function() {}, | 10 after: function() {}, |
12 get: function() {}, | 11 get: function() {}, |
13 on: function() {} | 12 on: function() {} |
14 }; | 13 }; |
15 windowNode = Y.one(window); | 14 windowNode = Y.one(window); |
16 app = new Y.juju.App({ | 15 app = new Y.juju.App({ |
17 env: env, | 16 env: env, |
18 container: container, | 17 container: container, |
19 viewContainer: container | 18 viewContainer: container |
20 }); | 19 }); |
21 app.activateHotkeys(); | 20 app.activateHotkeys(); |
22 done(); | 21 done(); |
23 }); | 22 }); |
24 }); | |
25 | 23 |
26 beforeEach(function() { | 24 beforeEach(function() { |
27 container = Y.Node.create('<div/>'); | 25 container = Y.Node.create('<div/>'); |
28 Y.one('#main').append(container); | 26 Y.one('#main').append(container); |
29 app.render(); | 27 app.render(); |
30 }); | 28 }); |
31 | 29 |
32 afterEach(function() { | 30 afterEach(function() { |
33 container.remove(true); | 31 container.remove(true); |
34 }); | 32 }); |
35 | 33 |
36 it('should listen for alt-S events', function() { | 34 it('should listen for alt-S events', function() { |
37 var searchInput = Y.Node.create('<input/>'); | 35 var searchInput = Y.Node.create('<input/>'); |
38 searchInput.set('id', 'charm-search-field'); | 36 searchInput.set('id', 'charm-search-field'); |
39 container.append(searchInput); | 37 container.append(searchInput); |
40 windowNode.simulate('keydown', { | 38 windowNode.simulate('keydown', { |
41 keyCode: 83, // "S" key. | 39 keyCode: 83, // "S" key. |
teknico
2012/11/22 15:06:01
Is the additional space before the "S" useful?
| |
42 altKey: true | 40 altKey: true |
41 }); | |
42 // Did charm-search-field get the focus? | |
43 assert.equal(searchInput, Y.one(document.activeElement)); | |
44 }); | |
45 | |
46 it('should listen for alt-E events', function() { | |
47 var altEtriggered = false; | |
48 app.on('navigateTo', function(ev) { | |
49 if (ev && ev.url === '/') { | |
50 altEtriggered = true; | |
51 } | |
52 // Avoid URL change performed by additional listeners. | |
53 ev.stopImmediatePropagation(); | |
54 }); | |
55 windowNode.simulate('keydown', { | |
56 keyCode: 69, // "E" key. | |
57 altKey: true | |
58 }); | |
59 assert.isTrue(altEtriggered); | |
60 }); | |
61 | |
62 }); | |
43 }); | 63 }); |
44 // Did charm-search-field get the focus? | |
45 assert.equal(searchInput, Y.one(document.activeElement)); | |
46 }); | |
47 | |
48 it('should listen for alt-E events', function() { | |
49 var altEtriggered = false; | |
50 app.on('navigateTo', function(ev) { | |
51 if (ev && ev.url === '/') { | |
52 altEtriggered = true; | |
53 } | |
54 // Avoid URL change performed by additional listeners. | |
55 ev.stopImmediatePropagation(); | |
56 }); | |
57 windowNode.simulate('keydown', { | |
58 keyCode: 69, // "E" key. | |
teknico
2012/11/22 15:06:01
Same comment as line 41 above.
| |
59 altKey: true | |
60 }); | |
61 assert.isTrue(altEtriggered); | |
62 }); | |
63 }); | |
LEFT | RIGHT |