~bcsaller/juju-gui/export-ui

« back to all changes in this revision

Viewing changes to test/test_app_hotkeys.js

  • Committer: Benjamin Saller
  • Author(s): Benjamin Saller
  • Date: 2013-05-05 17:28:34 UTC
  • mfrom: (647.1.8 help-popup)
  • Revision ID: bcsaller@gmail.com-20130505172834-0ocgmh0qcua2jphb
Popup Help Generated from new keyboard handling.

Replace exisitng keyboard support with new declarative system.
Generate popup help using declared bindings.

R=matthew.scott, gary.poster
CC=
https://codereview.appspot.com/9038045

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
'use strict';
2
2
 
3
3
describe('application hotkeys', function() {
4
 
  var app, container, windowNode, Y;
 
4
  var app, container, env, windowNode, Y;
5
5
 
6
6
  before(function(done) {
7
7
    Y = YUI(GlobalConfig).use(
8
8
        ['juju-gui', 'juju-tests-utils', 'node-event-simulate'], function(Y) {
9
 
          var env = {
 
9
          env = {
10
10
            after: function() {},
11
11
            get: function() {},
12
12
            on: function() {},
13
13
            set: function() {}
14
14
          };
15
15
          windowNode = Y.one(window);
16
 
          app = new Y.juju.App({
17
 
            env: env,
18
 
            container: container,
19
 
            viewContainer: container
20
 
          });
21
 
          app.showView(new Y.View());
22
 
          app.activateHotkeys();
23
16
          done();
24
17
        });
25
18
 
26
19
  });
27
20
 
28
21
  beforeEach(function() {
29
 
    container = Y.Node.create('<div/>');
 
22
    container = Y.namespace('juju-tests.utils').makeContainer();
 
23
    app = new Y.juju.App({
 
24
      env: env,
 
25
      container: container,
 
26
      viewContainer: container
 
27
    });
 
28
    app.showView(new Y.View());
 
29
    app.activateHotkeys();
 
30
 
30
31
    Y.one('#main').append(container);
31
32
    app.render();
32
33
  });
33
34
 
34
35
  afterEach(function() {
35
36
    container.remove(true);
36
 
  });
37
 
 
38
 
  it('should listen for alt-S events', function() {
 
37
    app.destroy({remove: true});
 
38
  });
 
39
 
 
40
  it('should listen for "?" events', function() {
 
41
    windowNode.simulate('keydown', {
 
42
      keyCode: 191, // "/" key.
 
43
      shiftKey: true
 
44
    });
 
45
    var help = Y.one('#shortcut-help');
 
46
    assert.equal(help.getStyle('display'), 'block');
 
47
  });
 
48
 
 
49
  it('should listen for Alt-S key events', function() {
39
50
    var searchInput = Y.Node.create('<input/>');
40
51
    searchInput.set('id', 'charm-search-field');
41
52
    container.append(searchInput);