##// END OF EJS Templates
Use waitFor instead of sleeping.
Jonathan Frederic -
Show More
@@ -16,8 +16,6 b' casper.notebook_test(function () {'
16 'print("Success")');
16 'print("Success")');
17 this.execute_cell_then(index);
17 this.execute_cell_then(index);
18
18
19 this.wait(500); // Wait for require.js async callbacks to load dependencies.
20
21 this.then(function () {
19 this.then(function () {
22 // Check if the widget manager has been instantiated.
20 // Check if the widget manager has been instantiated.
23 this.test.assert(this.evaluate(function() {
21 this.test.assert(this.evaluate(function() {
@@ -28,7 +26,7 b' casper.notebook_test(function () {'
28 throttle_index = this.append_cell(
26 throttle_index = this.append_cell(
29 'import time\n' +
27 'import time\n' +
30 'textbox = widgets.TextWidget()\n' +
28 'textbox = widgets.TextWidget()\n' +
31 'display(textbox)\n'+
29 'display(textbox)\n' +
32 'textbox.add_class("my-throttle-textbox")\n' +
30 'textbox.add_class("my-throttle-textbox")\n' +
33 'def handle_change(name, old, new):\n' +
31 'def handle_change(name, old, new):\n' +
34 ' print(len(new))\n' +
32 ' print(len(new))\n' +
@@ -47,12 +45,17 b' casper.notebook_test(function () {'
47 '.my-throttle-textbox'), 'Textbox exists.');
45 '.my-throttle-textbox'), 'Textbox exists.');
48
46
49 // Send 20 characters
47 // Send 20 characters
50 this.sendKeys('.my-throttle-textbox', '....................');
48 this.sendKeys('.my-throttle-textbox', '...................A');
51 });
49 });
52
50
53 this.wait(2000); // Wait for clicks to execute in kernel
51 this.waitFor(function check() {
54
52 var outputs = this.evaluate(function(i) {
55 this.then(function(){
53 return IPython.notebook.get_cell(i).output_area.outputs;
54 }, {i : throttle_index});
55 var output = outputs[outputs.length-1].text;
56 return (output[output.length-1] == 'A');
57
58 }, function then() {
56 var outputs = this.evaluate(function(i) {
59 var outputs = this.evaluate(function(i) {
57 return IPython.notebook.get_cell(i).output_area.outputs;
60 return IPython.notebook.get_cell(i).output_area.outputs;
58 }, {i : throttle_index});
61 }, {i : throttle_index});
@@ -34,10 +34,11 b' casper.notebook_test(function () {'
34 '.widget-area .widget-subarea button', 'click');
34 '.widget-area .widget-subarea button', 'click');
35 });
35 });
36
36
37 this.wait(500); // Wait for click to execute in kernel and write output
37 this.waitFor(function check() {
38
38 return (this.get_output_cell(button_index, 1).text == 'Clicked\n');
39 this.then(function () {
39 }, function then() {
40 this.test.assertEquals(this.get_output_cell(button_index, 1).text, 'Clicked\n',
40 this.test.assert(true, 'Button click event fires.');
41 'Button click event fires.');
41 }), function timeout() {
42 this.test.assert(false, 'Button click event fires.');
42 });
43 });
43 }); No newline at end of file
44 });
General Comments 0
You need to be logged in to leave comments. Login now