##// END OF EJS Templates
fix test
Bussonnier Matthias -
Show More
@@ -1,45 +1,47 b''
1 // Test widget button class
1 // Test widget button class
2 casper.notebook_test(function () {
2 casper.notebook_test(function () {
3 var button_index = this.append_cell(
3 var button_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 'button = widgets.Button(description="Title")\n' +
6 'button = widgets.Button(description="Title")\n' +
7 'display(button)\n' +
7 'display(button)\n' +
8 'print("Success")\n' +
8 'print("Success")\n' +
9 'def handle_click(sender):\n' +
9 'def handle_click(sender):\n' +
10 ' display("Clicked")\n' +
10 ' display("Clicked")\n' +
11 'button.on_click(handle_click)');
11 'button.on_click(handle_click)');
12 this.execute_cell_then(button_index, function(index){
12 this.execute_cell_then(button_index, function(index){
13 this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
13 this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
14 'Create button cell executed with correct output.');
14 'Create button cell executed with correct output.');
15 });
15 });
16
16
17 // Wait for the widgets to actually display.
17 // Wait for the widgets to actually display.
18 var widget_button_selector = '.widget-area .widget-subarea button';
18 var widget_button_selector = '.widget-area .widget-subarea button';
19 this.wait_for_element(button_index, widget_button_selector);
19 this.wait_for_element(button_index, widget_button_selector);
20
20
21 // Continue with the tests.
21 // Continue with the tests.
22 this.then(function() {
22 this.then(function() {
23 this.test.assert(this.cell_element_exists(button_index,
23 this.test.assert(this.cell_element_exists(button_index,
24 '.widget-area .widget-subarea'),
24 '.widget-area .widget-subarea'),
25 'Widget subarea exists.');
25 'Widget subarea exists.');
26
26
27 this.test.assert(this.cell_element_exists(button_index,
27 this.test.assert(this.cell_element_exists(button_index,
28 widget_button_selector),
28 widget_button_selector),
29 'Widget button exists.');
29 'Widget button exists.');
30
30
31 this.test.assert(this.cell_element_function(button_index,
31 this.test.assert(this.cell_element_function(button_index,
32 widget_button_selector, 'html')=='Title',
32 widget_button_selector, 'html')=='Title',
33 'Set button description.');
33 'Set button description.');
34
34
35 this.cell_element_function(button_index,
35 this.cell_element_function(button_index,
36 widget_button_selector, 'click');
36 widget_button_selector, 'click');
37 });
37 });
38
38
39 this.wait_for_output(button_index, 1);
39 this.wait_for_output(button_index, 1);
40
40
41 this.then(function () {
41 this.then(function () {
42 this.test.assertEquals(this.get_output_cell(button_index, 1).data['text/plain'], "'Clicked'",
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",
43 'Importing widgets show a warning');
44 this.test.assertEquals(this.get_output_cell(button_index, 2).data['text/plain'], "'Clicked'",
43 'Button click event fires.');
45 'Button click event fires.');
44 });
46 });
45 }); No newline at end of file
47 });
General Comments 0
You need to be logged in to leave comments. Login now