Index: [revision details] === added file '[revision details]' --- [revision details] 2012-01-01 00:00:00 +0000 +++ [revision details] 2012-01-01 00:00:00 +0000 @@ -0,0 +1,2 @@ +Old revision: nicola.larosa@canonical.com-20121126154256-1rsdfkfser0v5kkm +New revision: francesco.banconi@canonical.com-20121127142532-h924q85cp5i1yvlx Index: test/test_app.js === modified file 'test/test_app.js' --- test/test_app.js 2012-11-23 16:21:32 +0000 +++ test/test_app.js 2012-11-27 14:25:32 +0000 @@ -36,9 +36,6 @@ var app, container; beforeEach(function() { - if (container) { - container.remove(true); - } container = Y.one('#main') .appendChild(Y.Node.create('
')) .set('id', 'test-container') @@ -46,13 +43,18 @@ .append(Y.Node.create('') .set('id', 'environment-name')) .append(Y.Node.create('') - .set('id', 'provider-type')); + .set('id', 'provider-type')) + .hide(); app = new Y.juju.App( { container: container, viewContainer: container}); injectData(app); }); + afterEach(function() { + container.remove(true); + }); + it('should produce a valid index', function() { var container = app.get('container'); app.render(); @@ -104,14 +106,13 @@ it('should show the provider type, when available', function() { var providerType = 'excellent provider'; // Since no provider type has been set yet, none is displayed. - assert.equal( - container.one('#provider-type').get('text'), - ''); + assert.equal('', container.one('#provider-type').get('text')); app.env.set('providerType', providerType); // The provider type has been displayed. assert.equal( - container.one('#provider-type').get('text'), - 'on ' + providerType); + 'on ' + providerType, + container.one('#provider-type').get('text') + ); }); }); Index: test/test_app_hotkeys.js === modified file 'test/test_app_hotkeys.js' --- test/test_app_hotkeys.js 2012-11-23 16:21:32 +0000 +++ test/test_app_hotkeys.js 2012-11-27 14:25:32 +0000 @@ -3,9 +3,14 @@ YUI(GlobalConfig).use(['juju-gui', 'juju-tests-utils', 'node-event-simulate'], function(Y) { describe('application hotkeys', function() { - var app, container, env, conn, testUtils, windowNode; + var app, container, windowNode; - before(function() { + before(function(done) { + var env = { + after: function() {}, + get: function() {}, + on: function() {} + }; windowNode = Y.one(window); app = new Y.juju.App({ env: env, @@ -13,51 +18,46 @@ viewContainer: container }); app.activateHotkeys(); + done(); + }); + + beforeEach(function() { + container = Y.Node.create(''); + Y.one('#main').append(container); + app.render(); }); afterEach(function() { container.remove(true); }); - beforeEach(function() { - container = Y.one('#main').appendChild(Y.Node.create( - '')).set('id', 'test-container').append( - Y.Node.create('').set('id', 'charm-search-field')); - testUtils = Y.namespace('juju-tests.utils'); - env = { - get: function() { - }, - on: function() { - }, - after: function() { - } - }; - }); - it('should listen for alt-S events', function() { - app.render(); + var searchInput = Y.Node.create(''); + searchInput.set('id', 'charm-search-field'); + container.append(searchInput); windowNode.simulate('keydown', { - keyCode: 83, // "S" key + keyCode: 83, // "S" key. altKey: true }); // Did charm-search-field get the focus? - assert.equal(Y.one('#charm-search-field'), - Y.one(document.activeElement)); + assert.equal(searchInput, Y.one(document.activeElement)); }); it('should listen for alt-E events', function() { var altEtriggered = false; - app.on('navigateTo', function(param) { - if (param && param.url === '/') { + app.on('navigateTo', function(ev) { + if (ev && ev.url === '/') { altEtriggered = true; } + // Avoid URL change performed by additional listeners. + ev.stopImmediatePropagation(); }); - app.render(); windowNode.simulate('keydown', { - keyCode: 69, // "E" key + keyCode: 69, // "E" key. altKey: true }); assert.isTrue(altEtriggered); }); + }); });