Show More
@@ -1,55 +1,43 b'' | |||||
1 | // Test widget button class |
|
1 | // Test widget button class | |
2 | casper.notebook_test(function () { |
|
2 | casper.notebook_test(function () { | |
3 | index = this.append_cell( |
|
3 | index = this.append_cell( | |
4 | 'from IPython.html import widgets\n' + |
|
4 | 'from IPython.html import widgets\n' + | |
5 | 'from IPython.display import display, clear_output\n' + |
|
5 | 'from IPython.display import display, clear_output\n' + | |
6 | 'print("Success")'); |
|
6 | 'print("Success")'); | |
7 | this.execute_cell_then(index); |
|
7 | this.execute_cell_then(index); | |
8 |
|
8 | |||
9 | var button_index = this.append_cell( |
|
9 | var button_index = this.append_cell( | |
10 | 'button = widgets.ButtonWidget(description="Title")\n' + |
|
10 | 'button = widgets.ButtonWidget(description="Title")\n' + | |
11 | 'display(button)\n'+ |
|
11 | 'display(button)\n'+ | |
12 | 'print("Success")\n' + |
|
12 | 'print("Success")\n' + | |
13 | 'def handle_click(sender):\n' + |
|
13 | 'def handle_click(sender):\n' + | |
14 | ' print("Clicked")\n' + |
|
14 | ' print("Clicked")\n' + | |
15 | 'button.on_click(handle_click)'); |
|
15 | 'button.on_click(handle_click)'); | |
16 | this.execute_cell_then(button_index, function(index){ |
|
16 | this.execute_cell_then(button_index, function(index){ | |
17 |
|
17 | |||
18 | this.test.assert(this.get_output_cell(index).text == 'Success\n', |
|
18 | this.test.assert(this.get_output_cell(index).text == 'Success\n', | |
19 | 'Create button cell executed with correct output.'); |
|
19 | 'Create button cell executed with correct output.'); | |
20 |
|
20 | |||
21 | this.test.assert(this.cell_element_exists(index, |
|
21 | this.test.assert(this.cell_element_exists(index, | |
22 | '.widget-area .widget-subarea'), |
|
22 | '.widget-area .widget-subarea'), | |
23 | 'Widget subarea exists.'); |
|
23 | 'Widget subarea exists.'); | |
24 |
|
24 | |||
25 | this.test.assert(this.cell_element_exists(index, |
|
25 | this.test.assert(this.cell_element_exists(index, | |
26 | '.widget-area .widget-subarea button'), |
|
26 | '.widget-area .widget-subarea button'), | |
27 | 'Widget button exists.'); |
|
27 | 'Widget button exists.'); | |
28 |
|
28 | |||
29 | this.test.assert(this.cell_element_function(index, |
|
29 | this.test.assert(this.cell_element_function(index, | |
30 | '.widget-area .widget-subarea button', 'html')=='Title', |
|
30 | '.widget-area .widget-subarea button', 'html')=='Title', | |
31 | 'Set button description.'); |
|
31 | 'Set button description.'); | |
32 |
|
32 | |||
33 | this.cell_element_function(index, |
|
33 | this.cell_element_function(index, | |
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.wait(500); // Wait for click to execute in kernel and write output | |
38 |
|
38 | |||
39 | this.then(function () { |
|
39 | this.then(function () { | |
40 | this.test.assert(this.get_output_cell(button_index, 1).text == 'Clicked\n', |
|
40 | this.test.assert(this.get_output_cell(button_index, 1).text == 'Clicked\n', | |
41 | 'Button click event fires.'); |
|
41 | 'Button click event fires.'); | |
42 | }); |
|
42 | }); | |
43 |
|
||||
44 | // Close the button widget asynchronisly. |
|
|||
45 | index = this.append_cell('button.close()\n'); |
|
|||
46 | this.execute_cell(index); |
|
|||
47 |
|
||||
48 | this.wait(500); // Wait for the button to close. |
|
|||
49 |
|
||||
50 | this.then(function(){ |
|
|||
51 | this.test.assert(! this.cell_element_exists(button_index, |
|
|||
52 | '.widget-area .widget-subarea button'), |
|
|||
53 | 'Widget button doesn\'t exists.'); |
|
|||
54 | }); |
|
|||
55 | }); No newline at end of file |
|
43 | }); |
General Comments 0
You need to be logged in to leave comments.
Login now