Show More
@@ -1,47 +1,48 | |||
|
1 | 1 | // Test widget button class |
|
2 | 2 | casper.notebook_test(function () { |
|
3 | 3 | var button_index = this.append_cell( |
|
4 | 4 | 'from IPython.html import widgets\n' + |
|
5 | 5 | 'from IPython.display import display, clear_output\n' + |
|
6 | 6 | 'button = widgets.Button(description="Title")\n' + |
|
7 | 7 | 'display(button)\n' + |
|
8 | 8 | 'print("Success")\n' + |
|
9 | 9 | 'def handle_click(sender):\n' + |
|
10 | 10 | ' display("Clicked")\n' + |
|
11 | 11 | 'button.on_click(handle_click)'); |
|
12 | 12 | this.execute_cell_then(button_index, function(index){ |
|
13 | 13 | this.test.assertEquals(this.get_output_cell(index).text, 'Success\n', |
|
14 | 14 | 'Create button cell executed with correct output.'); |
|
15 | 15 | }); |
|
16 | 16 | |
|
17 | 17 | // Wait for the widgets to actually display. |
|
18 | 18 | var widget_button_selector = '.widget-area .widget-subarea button'; |
|
19 | 19 | this.wait_for_element(button_index, widget_button_selector); |
|
20 | 20 | |
|
21 | 21 | // Continue with the tests. |
|
22 | 22 | this.then(function() { |
|
23 | 23 | this.test.assert(this.cell_element_exists(button_index, |
|
24 | 24 | '.widget-area .widget-subarea'), |
|
25 | 25 | 'Widget subarea exists.'); |
|
26 | 26 | |
|
27 | 27 | this.test.assert(this.cell_element_exists(button_index, |
|
28 | 28 | widget_button_selector), |
|
29 | 29 | 'Widget button exists.'); |
|
30 | 30 | |
|
31 | 31 | this.test.assert(this.cell_element_function(button_index, |
|
32 | 32 | widget_button_selector, 'html')=='Title', |
|
33 | 33 | 'Set button description.'); |
|
34 | 34 | |
|
35 | 35 | this.cell_element_function(button_index, |
|
36 | 36 | widget_button_selector, 'click'); |
|
37 | 37 | }); |
|
38 | 38 | |
|
39 | 39 | this.wait_for_output(button_index, 1); |
|
40 | 40 | |
|
41 | 41 | this.then(function () { |
|
42 | this.test.assertEquals(this.get_output_cell(button_index, 1).text, "WARNING: The widget API is still considered experimental and \n may change by the next major release of IPython.\n", | |
|
42 | var warning_text = this.get_output_cell(button_index, 1).text; | |
|
43 | this.test.assertNotEquals(warning_text.indexOf('Warning'), -1, | |
|
43 | 44 | 'Importing widgets show a warning'); |
|
44 | 45 | this.test.assertEquals(this.get_output_cell(button_index, 2).data['text/plain'], "'Clicked'", |
|
45 | 46 | 'Button click event fires.'); |
|
46 | 47 | }); |
|
47 | 48 | }); |
General Comments 0
You need to be logged in to leave comments.
Login now