launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #09610
[Merge] lp:~rharding/launchpad/soyuz_yui35 into lp:launchpad
Richard Harding has proposed merging lp:~rharding/launchpad/soyuz_yui35 into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~rharding/launchpad/soyuz_yui35/+merge/113592
= Summary =
This adjusts the Soyuz JS tests to run under YUI 3.5
== Implementation Notes ==
This was purely a reorg of the tests to not use their own YUI config, but use
the shared testrunner. No changes to the tests or modules itself was required.
== LoC Qualification ==
It's a negative LoC.
--
https://code.launchpad.net/~rharding/launchpad/soyuz_yui35/+merge/113592
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rharding/launchpad/soyuz_yui35 into lp:launchpad.
=== modified file 'lib/lp/soyuz/javascript/tests/test_archive-packages.html'
--- lib/lp/soyuz/javascript/tests/test_archive-packages.html 2012-03-14 04:41:36 +0000
+++ lib/lp/soyuz/javascript/tests/test_archive-packages.html 2012-07-05 14:31:25 +0000
@@ -48,7 +48,6 @@
</head>
<body class="yui3-skin-sam">
<ul id="suites">
- <!-- <li>lp.large_indicator.test</li> -->
<li>lp.soyuz.archive_packages.test</li>
</ul>
=== modified file 'lib/lp/soyuz/javascript/tests/test_archivesubscribers_index.html'
--- lib/lp/soyuz/javascript/tests/test_archivesubscribers_index.html 2012-03-14 04:41:36 +0000
+++ lib/lp/soyuz/javascript/tests/test_archivesubscribers_index.html 2012-07-05 14:31:25 +0000
@@ -34,13 +34,13 @@
<!-- <link rel="stylesheet" href="../assets/archivesubscribers_index-core.css" /> -->
<!-- The test suite. -->
- <script type="text/javascript" src="archivesubscribers_index.js"></script>
+ <script type="text/javascript" src="test_archivesubscribers_index.js"></script>
</head>
<body class="yui3-skin-sam">
<ul id="suites">
<!-- <li>lp.large_indicator.test</li> -->
- <li>lp.archivesubscribers_index.test</li>
+ <li>lp.soyuz.archivesubscribers_index.test</li>
</ul>
<h1>Testing the ArchiveSubscribersIndex javascript</h1>
=== renamed file 'lib/lp/soyuz/javascript/tests/archivesubscribers_index.js' => 'lib/lp/soyuz/javascript/tests/test_archivesubscribers_index.js'
--- lib/lp/soyuz/javascript/tests/archivesubscribers_index.js 2011-06-07 16:42:11 +0000
+++ lib/lp/soyuz/javascript/tests/test_archivesubscribers_index.js 2012-07-05 14:31:25 +0000
@@ -1,151 +1,131 @@
-/* Copyright 2009 Canonical Ltd. This software is licensed under the
- GNU Affero General Public License version 3 (see the file LICENSE). */
-
-YUI({
- base: '../../../../canonical/launchpad/icing/yui/',
- filter: 'raw',
- combine: false,
- fetchCSS: false
- }).use(
- 'test', 'console', 'lp.soyuz.archivesubscribers_index', function(Y) {
-
-var Assert = Y.Assert; // For easy access to isTrue(), etc.
-
-var suite = new Y.Test.Suite("ArchiveSubscriber Tests");
-
-suite.add(new Y.Test.Case({
-
- name: 'add-subscriber',
-
- setUp: function() {
- this.add_subscriber_placeholder = Y.one(
- '#add-subscriber-placeholder');
- this.archive_subscribers_table_body = Y.one(
- '#archive-subscribers').one('tbody');
- this.error_div = Y.one('#errors');
- this.subscribers_div = Y.one('#subscribers');
-
-
- // Ensure there are no errors displayed.
- this.error_div.set('innerHTML', '');
-
- // Ensure the add subscriber place-holder is empty.
- this.add_subscriber_placeholder.set('innerHTML', '');
-
- // Ensure the table has the correct structure.
- this.archive_subscribers_table_body.set(
- 'innerHTML', [
- '<tr class="add-subscriber">',
- '<td>New 1</td>',
- '<td>New 2</td>',
- '<td>New 3</td>',
- '<td>Add</td>',
- '</tr>',
- '<tr>',
- '<td>Existing 1</td>',
- '<td>Existing 2</td>',
- '<td>Existing 3</td>',
- '<td>Edit</td>',
- '</tr>'
- ].join(''));
-
- this.add_subscriber_row = Y.one(
- '#archive-subscribers .add-subscriber');
- },
-
- test_add_row_displayed_by_default: function() {
- // The add subscriber row is displayed when the JS is not run.
- Assert.areEqual(
- 'table-row', this.add_subscriber_row.getStyle('display'),
- 'The add subscriber row should display when the js is not run.');
- },
-
- test_subscribers_displayed_by_default: function() {
- // The subscribers section is displayed when the js is not run.
- Assert.areEqual(
- 'block', this.subscribers_div.getStyle('display'),
- 'The subscribers section should display without js.');
- },
-
- test_add_row_hidden_after_setup: function() {
- // The add subscriber row is hidden during setup.
- Y.lp.soyuz.archivesubscribers_index.setup_archivesubscribers_index();
- Assert.areEqual(
- 'none', this.add_subscriber_row.getStyle('display'),
- 'The add subscriber row should be hidden during setup.');
- },
-
- test_subscribers_section_displayed_after_setup: function() {
- // The subscribers div normally remains displayed after setup.
- Y.lp.soyuz.archivesubscribers_index.setup_archivesubscribers_index();
- Assert.areEqual(
- 'block', this.subscribers_div.getStyle('display'),
- 'The subscribers div should remain displayed after setup.');
- },
-
- test_subscribers_section_hidden_when_no_subscribers: function() {
- // The subscribers div is hidden when there are no subscribers.
-
- // Add a paragraph with the no-subscribers id.
- this.error_div.set('innerHTML', '<p id="no-subscribers">blah</p>');
- Y.lp.soyuz.archivesubscribers_index.setup_archivesubscribers_index();
- Assert.areEqual(
- 'none', this.subscribers_div.getStyle('display'),
- 'The subscribers div should be hidden when there are ' +
- 'no subscribers.');
- },
-
- test_add_row_displayed_when_errors_present: function() {
- // The add subscriber row is not hidden if there are validation
- // errors.
-
- // Add an error paragraph.
- this.error_div.set('innerHTML', '<p class="error message">Blah</p>');
- Y.lp.soyuz.archivesubscribers_index.setup_archivesubscribers_index();
- Assert.areEqual(
- 'table-row', this.add_subscriber_row.getStyle('display'),
- 'The add subscriber row should not be hidden if there are ' +
- 'errors present.');
- },
-
- test_add_access_link_added_after_setup: function() {
- // The 'Add access' link is created during setup.
-
- Y.lp.soyuz.archivesubscribers_index.setup_archivesubscribers_index();
- Assert.areEqual(
- '<a class="js-action sprite add" href="#">Add access</a>',
- this.add_subscriber_placeholder.get('innerHTML'),
- "The 'Add access' link should be created during setup.");
- },
-
- test_click_add_access_displays_add_row: function() {
- // The add subscriber row is displayed after clicking 'Add access'.
- Y.lp.soyuz.archivesubscribers_index.setup_archivesubscribers_index();
- var link_node = this.add_subscriber_placeholder.one('a');
- Assert.areEqual(
- 'Add access', link_node.get('innerHTML'));
-
- Y.Event.simulate(Y.Node.getDOMNode(link_node), 'click');
-
- Assert.areEqual(
- 'table-row', this.add_subscriber_row.getStyle('display'),
- "The add subscriber row should be displayed after clicking " +
- "'Add access'");
- }
-}));
-
-Y.Test.Runner.on('complete', function(data) {
- window.status = '::::' + JSON.stringify(data);
-});
-Y.Test.Runner.add(suite);
-
-var yconsole = new Y.Console({
- newestOnTop: false
-});
-yconsole.render('#log');
-
-Y.on('domready', function() {
- Y.Test.Runner.run();
-});
-
+/* Copyright (c) 2009-2012 Canonical Ltd. All rights reserved. */
+
+YUI.add('lp.soyuz.archivesubscribers_index.test', function (Y) {
+ var Assert = Y.Assert; // For easy access to isTrue(), etc.
+ var tests = Y.namespace('lp.soyuz.archivesubscribers_index.test');
+ tests.suite = new Y.Test.Suite('soyuz.archivesubscribers_index Tests');
+
+ tests.suite.add(new Y.Test.Case({
+
+ name: 'add-subscriber',
+
+ setUp: function() {
+ this.add_subscriber_placeholder = Y.one(
+ '#add-subscriber-placeholder');
+ this.archive_subscribers_table_body = Y.one(
+ '#archive-subscribers').one('tbody');
+ this.error_div = Y.one('#errors');
+ this.subscribers_div = Y.one('#subscribers');
+
+
+ // Ensure there are no errors displayed.
+ this.error_div.set('innerHTML', '');
+
+ // Ensure the add subscriber place-holder is empty.
+ this.add_subscriber_placeholder.set('innerHTML', '');
+
+ // Ensure the table has the correct structure.
+ this.archive_subscribers_table_body.set(
+ 'innerHTML', [
+ '<tr class="add-subscriber">',
+ '<td>New 1</td>',
+ '<td>New 2</td>',
+ '<td>New 3</td>',
+ '<td>Add</td>',
+ '</tr>',
+ '<tr>',
+ '<td>Existing 1</td>',
+ '<td>Existing 2</td>',
+ '<td>Existing 3</td>',
+ '<td>Edit</td>',
+ '</tr>'
+ ].join(''));
+
+ this.add_subscriber_row = Y.one(
+ '#archive-subscribers .add-subscriber');
+ },
+
+ test_add_row_displayed_by_default: function() {
+ // The add subscriber row is displayed when the JS is not run.
+ Assert.areEqual(
+ 'table-row', this.add_subscriber_row.getStyle('display'),
+ 'The add subscriber row should display when the js is not run.');
+ },
+
+ test_subscribers_displayed_by_default: function() {
+ // The subscribers section is displayed when the js is not run.
+ Assert.areEqual(
+ 'block', this.subscribers_div.getStyle('display'),
+ 'The subscribers section should display without js.');
+ },
+
+ test_add_row_hidden_after_setup: function() {
+ // The add subscriber row is hidden during setup.
+ Y.lp.soyuz.archivesubscribers_index.setup_archivesubscribers_index();
+ Assert.areEqual(
+ 'none', this.add_subscriber_row.getStyle('display'),
+ 'The add subscriber row should be hidden during setup.');
+ },
+
+ test_subscribers_section_displayed_after_setup: function() {
+ // The subscribers div normally remains displayed after setup.
+ Y.lp.soyuz.archivesubscribers_index.setup_archivesubscribers_index();
+ Assert.areEqual(
+ 'block', this.subscribers_div.getStyle('display'),
+ 'The subscribers div should remain displayed after setup.');
+ },
+
+ test_subscribers_section_hidden_when_no_subscribers: function() {
+ // The subscribers div is hidden when there are no subscribers.
+
+ // Add a paragraph with the no-subscribers id.
+ this.error_div.set('innerHTML', '<p id="no-subscribers">blah</p>');
+ Y.lp.soyuz.archivesubscribers_index.setup_archivesubscribers_index();
+ Assert.areEqual(
+ 'none', this.subscribers_div.getStyle('display'),
+ 'The subscribers div should be hidden when there are ' +
+ 'no subscribers.');
+ },
+
+ test_add_row_displayed_when_errors_present: function() {
+ // The add subscriber row is not hidden if there are validation
+ // errors.
+
+ // Add an error paragraph.
+ this.error_div.set('innerHTML', '<p class="error message">Blah</p>');
+ Y.lp.soyuz.archivesubscribers_index.setup_archivesubscribers_index();
+ Assert.areEqual(
+ 'table-row', this.add_subscriber_row.getStyle('display'),
+ 'The add subscriber row should not be hidden if there are ' +
+ 'errors present.');
+ },
+
+ test_add_access_link_added_after_setup: function() {
+ // The 'Add access' link is created during setup.
+
+ Y.lp.soyuz.archivesubscribers_index.setup_archivesubscribers_index();
+ Assert.areEqual(
+ '<a class="js-action sprite add" href="#">Add access</a>',
+ this.add_subscriber_placeholder.get('innerHTML'),
+ "The 'Add access' link should be created during setup.");
+ },
+
+ test_click_add_access_displays_add_row: function() {
+ // The add subscriber row is displayed after clicking 'Add access'.
+ Y.lp.soyuz.archivesubscribers_index.setup_archivesubscribers_index();
+ var link_node = this.add_subscriber_placeholder.one('a');
+ Assert.areEqual(
+ 'Add access', link_node.get('innerHTML'));
+
+ Y.Event.simulate(Y.Node.getDOMNode(link_node), 'click');
+
+ Assert.areEqual(
+ 'table-row', this.add_subscriber_row.getStyle('display'),
+ "The add subscriber row should be displayed after clicking " +
+ "'Add access'");
+ }
+ }));
+}, '0.1', {
+ requires: ['test', 'lp.testing.helpers', 'console',
+ 'lp.soyuz.archivesubscribers_index']
});
=== renamed file 'lib/lp/soyuz/javascript/tests/test_lp_dynamic_dom_updater.html' => 'lib/lp/soyuz/javascript/tests/test_dynamic_dom_updater.html'
--- lib/lp/soyuz/javascript/tests/test_lp_dynamic_dom_updater.html 2012-03-14 04:41:36 +0000
+++ lib/lp/soyuz/javascript/tests/test_dynamic_dom_updater.html 2012-07-05 14:31:25 +0000
@@ -34,13 +34,12 @@
<!-- <link rel="stylesheet" href="../assets/dynamic_dom_updater-core.css" /> -->
<!-- The test suite. -->
- <script type="text/javascript" src="lp_dynamic_dom_updater.js"></script>
+ <script type="text/javascript" src="test_dynamic_dom_updater.js"></script>
</head>
<body class="yui3-skin-sam">
<ul id="suites">
- <!-- <li>lp.large_indicator.test</li> -->
- <li>lp.dynamic_dom_updater.test</li>
+ <li>lp.soyuz.dynamic_dom_updater.test</li>
</ul>
<div id="lp_dynamic_dom_updater_example">
=== renamed file 'lib/lp/soyuz/javascript/tests/lp_dynamic_dom_updater.js' => 'lib/lp/soyuz/javascript/tests/test_dynamic_dom_updater.js'
--- lib/lp/soyuz/javascript/tests/lp_dynamic_dom_updater.js 2012-05-31 15:50:46 +0000
+++ lib/lp/soyuz/javascript/tests/test_dynamic_dom_updater.js 2012-07-05 14:31:25 +0000
@@ -1,295 +1,275 @@
-/* Copyright 2009 Canonical Ltd. This software is licensed under the
- GNU Affero General Public License version 3 (see the file LICENSE). */
-
-YUI({
- base: '../../../../canonical/launchpad/icing/yui/',
- filter: 'raw',
- combine: false,
- fetchCSS: false
- }).use('test', 'console', 'lp.soyuz.dynamic_dom_updater', function(Y) {
-
-var Assert = Y.Assert; // For easy access to isTrue(), etc.
-
-var suite = new Y.Test.Suite("DynamicDomUpdater Tests");
-
-suite.add(new Y.Test.Case({
-
- name: 'dom_updater',
-
- setUp: function() {
- this.eg_div = Y.Node.create(
- '<div>Default text to start with.</div>');
- this.config = {
- domUpdateFunction: function(node, data_object) {
- node.set('innerHTML', data_object.msg);
- }
- };
- },
-
- test_dom_updater_is_pluggable: function() {
- // Plugging the DomUpdater adds an 'updater' attribute.
- Assert.isUndefined(
- this.eg_div.updater,
- "Sanity check: initially there is no updater attribute.");
-
- this.eg_div.plug(
- Y.lp.soyuz.dynamic_dom_updater.DomUpdater, this.config);
-
- Assert.isNotUndefined(
- this.eg_div.updater,
- "After plugging, the object has an 'updater' attribute.");
-
- Assert.isInstanceOf(
- Y.lp.soyuz.dynamic_dom_updater.DomUpdater,
- this.eg_div.updater,
- "DomUpdater was not plugged correctly.");
- },
-
- test_update_function_called_with_correct_params: function() {
- // Calling the update function results in the user-provided update
- // receiving the correct data.
- Assert.areEqual(
- 'Default text to start with.',
- this.eg_div.get('innerHTML'),
- "Sanity check that the innerHTML of our example div has not" +
- "been modified.");
-
- this.eg_div.plug(
- Y.lp.soyuz.dynamic_dom_updater.DomUpdater, this.config);
- this.eg_div.updater.update({msg: "Boo. I've changed."});
- Assert.areEqual(
- "Boo. I've changed.",
- this.eg_div.get('innerHTML'),
- "The user-provided function is executed with the " +
- "supplied data.");
- }
-}));
-
-suite.add(new Y.Test.Case({
-
- name: 'dynamic_dom_updater',
-
- setUp: function() {
- this.eg_div = Y.Node.create(
- '<div>Default text to start with.</div>');
- this.lp_client_mock = Y.Mock();
- this.config = {
- domUpdateFunction: function(node, data_object) {
- node.set('innerHTML', data_object.msg);
- },
- uri: 'http://example.com',
- api_method_name: 'my_method',
- interval: 1,
- lp_client: this.lp_client_mock,
- long_processing_time: 10,
- short_processing_time: 5
- };
-
- // We expect only one named_get call on the lp client
- Y.Mock.expect(this.lp_client_mock, {
- method: "named_get",
- args: ['http://example.com', 'my_method', Y.Mock.Value.Object],
- callCount: 1
- });
- },
-
- test_dynamic_dom_updater_is_pluggable: function() {
- // Plugging the DomUpdater adds an 'updater' attribute.
-
- Assert.isUndefined(
- this.eg_div.updater,
- "Sanity check: initially there is no updater attribute.");
-
- this.eg_div.plug(
- Y.lp.soyuz.dynamic_dom_updater.DynamicDomUpdater, this.config);
-
- Assert.isNotUndefined(
- this.eg_div.updater,
- "After plugging, the object has an 'updater' attribute.");
-
- Assert.isInstanceOf(
- Y.lp.soyuz.dynamic_dom_updater.DynamicDomUpdater,
- this.eg_div.updater,
- "DynamicDomUpdater was not plugged correctly.");
- },
-
- test_no_further_request_if_previous_response_not_received: function() {
- // Requests to the LP API should only be re-issued if a successful
- // response was received previously.
-
- this.eg_div.plug(
- Y.lp.soyuz.dynamic_dom_updater.DynamicDomUpdater, this.config);
-
- // Verify that our expectation of only one named_get was met:
- this.wait(function() {
- Y.Mock.verify(this.lp_client_mock);
- }, 5);
- },
-
- test_second_response_when_previous_request_successful: function() {
- // A second request to the LP API should be issued if the
- // response from the first was successfully received
-
- // Set an expectation for two calls to named_get
- Y.Mock.expect(this.lp_client_mock, {
- method: "named_get",
- args: ['http://example.com', 'my_method', Y.Mock.Value.Object],
- callCount: 2
- });
-
- this.eg_div.plug(
- Y.lp.soyuz.dynamic_dom_updater.DynamicDomUpdater, this.config);
-
- // Wait 5ms just to ensure that the DynamicDomUpdater finishes
- // its initialization.
- this.wait(function() {
- this.eg_div.updater._handleSuccess({msg: "Boo. I've changed."});
-
- // Verify that both requests were issued.
+/* Copyright (c) 2009-2012 Canonical Ltd. All rights reserved. */
+YUI.add('lp.soyuz.dynamic_dom_updater.test', function (Y) {
+ var Assert = Y.Assert; // For easy access to isTrue(), etc.
+ var tests = Y.namespace('lp.soyuz.dynamic_dom_updater.test');
+ tests.suite = new Y.Test.Suite('soyuz.dynamic_dom_updater Tests');
+
+ tests.suite.add(new Y.Test.Case({
+
+ name: 'dom_updater',
+
+ setUp: function() {
+ this.eg_div = Y.Node.create(
+ '<div>Default text to start with.</div>');
+ this.config = {
+ domUpdateFunction: function(node, data_object) {
+ node.set('innerHTML', data_object.msg);
+ }
+ };
+ },
+
+ test_dom_updater_is_pluggable: function() {
+ // Plugging the DomUpdater adds an 'updater' attribute.
+ Assert.isUndefined(
+ this.eg_div.updater,
+ "Sanity check: initially there is no updater attribute.");
+
+ this.eg_div.plug(
+ Y.lp.soyuz.dynamic_dom_updater.DomUpdater, this.config);
+
+ Assert.isNotUndefined(
+ this.eg_div.updater,
+ "After plugging, the object has an 'updater' attribute.");
+
+ Assert.isInstanceOf(
+ Y.lp.soyuz.dynamic_dom_updater.DomUpdater,
+ this.eg_div.updater,
+ "DomUpdater was not plugged correctly.");
+ },
+
+ test_update_function_called_with_correct_params: function() {
+ // Calling the update function results in the user-provided update
+ // receiving the correct data.
+ Assert.areEqual(
+ 'Default text to start with.',
+ this.eg_div.get('innerHTML'),
+ "Sanity check that the innerHTML of our example div has not" +
+ "been modified.");
+
+ this.eg_div.plug(
+ Y.lp.soyuz.dynamic_dom_updater.DomUpdater, this.config);
+ this.eg_div.updater.update({msg: "Boo. I've changed."});
+ Assert.areEqual(
+ "Boo. I've changed.",
+ this.eg_div.get('innerHTML'),
+ "The user-provided function is executed with the " +
+ "supplied data.");
+ }
+ }));
+
+ tests.suite.add(new Y.Test.Case({
+ name: 'dynamic_dom_updater',
+
+ setUp: function() {
+ this.eg_div = Y.Node.create(
+ '<div>Default text to start with.</div>');
+ this.lp_client_mock = Y.Mock();
+ this.config = {
+ domUpdateFunction: function(node, data_object) {
+ node.set('innerHTML', data_object.msg);
+ },
+ uri: 'http://example.com',
+ api_method_name: 'my_method',
+ interval: 1,
+ lp_client: this.lp_client_mock,
+ long_processing_time: 10,
+ short_processing_time: 5
+ };
+
+ // We expect only one named_get call on the lp client
+ Y.Mock.expect(this.lp_client_mock, {
+ method: "named_get",
+ args: ['http://example.com', 'my_method', Y.Mock.Value.Object],
+ callCount: 1
+ });
+ },
+
+ test_dynamic_dom_updater_is_pluggable: function() {
+ // Plugging the DomUpdater adds an 'updater' attribute.
+
+ Assert.isUndefined(
+ this.eg_div.updater,
+ "Sanity check: initially there is no updater attribute.");
+
+ this.eg_div.plug(
+ Y.lp.soyuz.dynamic_dom_updater.DynamicDomUpdater, this.config);
+
+ Assert.isNotUndefined(
+ this.eg_div.updater,
+ "After plugging, the object has an 'updater' attribute.");
+
+ Assert.isInstanceOf(
+ Y.lp.soyuz.dynamic_dom_updater.DynamicDomUpdater,
+ this.eg_div.updater,
+ "DynamicDomUpdater was not plugged correctly.");
+ },
+
+ test_no_further_request_if_previous_response_not_received: function() {
+ // Requests to the LP API should only be re-issued if a successful
+ // response was received previously.
+
+ this.eg_div.plug(
+ Y.lp.soyuz.dynamic_dom_updater.DynamicDomUpdater, this.config);
+
+ // Verify that our expectation of only one named_get was met:
this.wait(function() {
Y.Mock.verify(this.lp_client_mock);
}, 5);
-
- }, 5);
- },
-
- test_actual_interval_doubled_if_request_too_long: function() {
- // The actual polling interval is doubled if the elapsed time
- // for the previous request was greater than the
- // long_processing_time attribute.
- this.eg_div.plug(
- Y.lp.soyuz.dynamic_dom_updater.DynamicDomUpdater, this.config);
-
- // Wait 5ms just to ensure that the DynamicDomUpdater finishes
- // its initialization.
- this.wait(function() {
- var updated = this.eg_div.updater._updateActualInterval(
- this.config.long_processing_time + 1);
-
- // The actual interval is updated.
- Assert.isTrue(
- updated,
- "Poll interval changed if request takes too long.");
-
- // The actual interval should have doubled from 1ms to 2ms.
- Assert.areEqual(
- this.config.interval * 2,
- this.eg_div.updater._actual_interval,
- "Poll interval doubled if request takes too long.");
-
- }, 5);
- },
-
- test_actual_interval_unchanged_if_request_normal: function() {
- // The actual polling interval remains unchanged if the elapsed time
- // for the previous request was within the short/long processing
- // times.
- this.eg_div.plug(
- Y.lp.soyuz.dynamic_dom_updater.DynamicDomUpdater, this.config);
-
- // Wait 5ms just to ensure that the DynamicDomUpdater finishes
- // its initialization.
- this.wait(function() {
- var updated = this.eg_div.updater._updateActualInterval(
- (this.config.long_processing_time +
- this.config.short_processing_time) / 2);
-
- // The actual interval is not updated.
- Assert.isFalse(
- updated,
- "Poll interval unchanged if request is timely.");
-
- // The actual interval is unchanged.
- Assert.areEqual(
- this.config.interval,
- this.eg_div.updater._actual_interval,
- "Poll interval unchanged if request is timely.");
-
- }, 5);
- },
-
- test_actual_interval_halved_if_request_is_quick: function() {
- // The actual polling interval is halved if the elapsed time
- // for the previous request was less than the short_processing_time
- this.eg_div.plug(
- Y.lp.soyuz.dynamic_dom_updater.DynamicDomUpdater, this.config);
-
- // Wait 5ms just to ensure that the DynamicDomUpdater finishes
- // its initialization.
- this.wait(function() {
-
- // Ensure the current actual polling time is more than double the
- // requested interval.
- var actual_interval = this.config.interval * 4;
- this.eg_div.updater._actual_interval = actual_interval;
- var updated = this.eg_div.updater._updateActualInterval(
- this.config.short_processing_time - 1);
-
- // The actual interval is updated.
- Assert.isTrue(
- updated,
- "Poll interval changed if request is faster than expected.");
-
- // The actual interval is changed.
- Assert.areEqual(
- actual_interval / 2,
- this.eg_div.updater._actual_interval,
- "Poll interval is halved if request is faster than " +
- "expected.");
-
- }, 5);
- },
-
- test_actual_never_less_than_original_interval: function() {
- // Even if the processing time is quick, the actual interval
- // is never smaller than the interval set in the configuration.
-
- this.eg_div.plug(
- Y.lp.soyuz.dynamic_dom_updater.DynamicDomUpdater, this.config);
-
- // Wait 5ms just to ensure that the DynamicDomUpdater finishes
- // its initialization.
- this.wait(function() {
- var interval = 10;
-
- // Update the configuration interval:
- this.eg_div.updater.set('interval', interval);
-
- // Ensure the current actual polling time is less than double the
- // requested interval.
- this.eg_div.updater._actual_interval = (interval * 2) - 2;
- var updated = this.eg_div.updater._updateActualInterval(
- this.config.short_processing_time - 1);
-
- // The actual interval is updated.
- Assert.isTrue(
- updated,
- "Poll interval changed if request is faster than expected.");
-
- // The actual interval is not smaller than the configuration
- // interval.
- Assert.areEqual(
- interval,
- this.eg_div.updater._actual_interval,
- "Actual interval never goes below config interval.");
-
- }, 5);
- }
-
-}));
-
- Y.Test.Runner.on('complete', function(data) {
- window.status = '::::' + JSON.stringify(data);
- });
- Y.Test.Runner.add(suite);
-
- var yconsole = new Y.Console({
- newestOnTop: false
- });
- yconsole.render('#log');
-
- Y.on('domready', function() {
- Y.Test.Runner.run();
- });
-
+ },
+
+ test_second_response_when_previous_request_successful: function() {
+ // A second request to the LP API should be issued if the
+ // response from the first was successfully received
+
+ // Set an expectation for two calls to named_get
+ Y.Mock.expect(this.lp_client_mock, {
+ method: "named_get",
+ args: ['http://example.com', 'my_method', Y.Mock.Value.Object],
+ callCount: 2
+ });
+
+ this.eg_div.plug(
+ Y.lp.soyuz.dynamic_dom_updater.DynamicDomUpdater, this.config);
+
+ // Wait 5ms just to ensure that the DynamicDomUpdater finishes
+ // its initialization.
+ this.wait(function() {
+ this.eg_div.updater._handleSuccess({msg: "Boo. I've changed."});
+
+ // Verify that both requests were issued.
+ this.wait(function() {
+ Y.Mock.verify(this.lp_client_mock);
+ }, 5);
+
+ }, 5);
+ },
+
+ test_actual_interval_doubled_if_request_too_long: function() {
+ // The actual polling interval is doubled if the elapsed time
+ // for the previous request was greater than the
+ // long_processing_time attribute.
+ this.eg_div.plug(
+ Y.lp.soyuz.dynamic_dom_updater.DynamicDomUpdater, this.config);
+
+ // Wait 5ms just to ensure that the DynamicDomUpdater finishes
+ // its initialization.
+ this.wait(function() {
+ var updated = this.eg_div.updater._updateActualInterval(
+ this.config.long_processing_time + 1);
+
+ // The actual interval is updated.
+ Assert.isTrue(
+ updated,
+ "Poll interval changed if request takes too long.");
+
+ // The actual interval should have doubled from 1ms to 2ms.
+ Assert.areEqual(
+ this.config.interval * 2,
+ this.eg_div.updater._actual_interval,
+ "Poll interval doubled if request takes too long.");
+
+ }, 5);
+ },
+
+ test_actual_interval_unchanged_if_request_normal: function() {
+ // The actual polling interval remains unchanged if the elapsed time
+ // for the previous request was within the short/long processing
+ // times.
+ this.eg_div.plug(
+ Y.lp.soyuz.dynamic_dom_updater.DynamicDomUpdater, this.config);
+
+ // Wait 5ms just to ensure that the DynamicDomUpdater finishes
+ // its initialization.
+ this.wait(function() {
+ var updated = this.eg_div.updater._updateActualInterval(
+ (this.config.long_processing_time +
+ this.config.short_processing_time) / 2);
+
+ // The actual interval is not updated.
+ Assert.isFalse(
+ updated,
+ "Poll interval unchanged if request is timely.");
+
+ // The actual interval is unchanged.
+ Assert.areEqual(
+ this.config.interval,
+ this.eg_div.updater._actual_interval,
+ "Poll interval unchanged if request is timely.");
+
+ }, 5);
+ },
+
+ test_actual_interval_halved_if_request_is_quick: function() {
+ // The actual polling interval is halved if the elapsed time
+ // for the previous request was less than the short_processing_time
+ this.eg_div.plug(
+ Y.lp.soyuz.dynamic_dom_updater.DynamicDomUpdater, this.config);
+
+ // Wait 5ms just to ensure that the DynamicDomUpdater finishes
+ // its initialization.
+ this.wait(function() {
+
+ // Ensure the current actual polling time is more than double the
+ // requested interval.
+ var actual_interval = this.config.interval * 4;
+ this.eg_div.updater._actual_interval = actual_interval;
+ var updated = this.eg_div.updater._updateActualInterval(
+ this.config.short_processing_time - 1);
+
+ // The actual interval is updated.
+ Assert.isTrue(
+ updated,
+ "Poll interval changed if request is faster than expected.");
+
+ // The actual interval is changed.
+ Assert.areEqual(
+ actual_interval / 2,
+ this.eg_div.updater._actual_interval,
+ "Poll interval is halved if request is faster than " +
+ "expected.");
+
+ }, 5);
+ },
+
+ test_actual_never_less_than_original_interval: function() {
+ // Even if the processing time is quick, the actual interval
+ // is never smaller than the interval set in the configuration.
+
+ this.eg_div.plug(
+ Y.lp.soyuz.dynamic_dom_updater.DynamicDomUpdater, this.config);
+
+ // Wait 5ms just to ensure that the DynamicDomUpdater finishes
+ // its initialization.
+ this.wait(function() {
+ var interval = 10;
+
+ // Update the configuration interval:
+ this.eg_div.updater.set('interval', interval);
+
+ // Ensure the current actual polling time is less than double the
+ // requested interval.
+ this.eg_div.updater._actual_interval = (interval * 2) - 2;
+ var updated = this.eg_div.updater._updateActualInterval(
+ this.config.short_processing_time - 1);
+
+ // The actual interval is updated.
+ Assert.isTrue(
+ updated,
+ "Poll interval changed if request is faster than expected.");
+
+ // The actual interval is not smaller than the configuration
+ // interval.
+ Assert.areEqual(
+ interval,
+ this.eg_div.updater._actual_interval,
+ "Actual interval never goes below config interval.");
+
+ }, 5);
+ }
+
+ }));
+
+}, '0.1', {
+ requires: ['test', 'lp.testing.helpers', 'console',
+ 'lp.soyuz.dynamic_dom_updater']
});
=== modified file 'standard_test_template.js'
--- standard_test_template.js 2012-06-28 22:33:35 +0000
+++ standard_test_template.js 2012-07-05 14:31:25 +0000
@@ -18,4 +18,6 @@
}));
-}, '0.1', {'requires': ['test', 'lp.testing.helpers', 'console', 'lp.${LIBRARY}']});
+}, '0.1', {
+ requires: ['test', 'lp.testing.helpers', 'console', 'lp.${LIBRARY}']
+});
Follow ups