##// END OF EJS Templates
Merge pull request #7211 from minrk/warning-test...
Min RK -
r19533:caa31e36 merge
parent child Browse files
Show More
@@ -1,47 +1,48 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).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 'Importing widgets show a warning');
44 'Importing widgets show a warning');
44 this.test.assertEquals(this.get_output_cell(button_index, 2).data['text/plain'], "'Clicked'",
45 this.test.assertEquals(this.get_output_cell(button_index, 2).data['text/plain'], "'Clicked'",
45 'Button click event fires.');
46 'Button click event fires.');
46 });
47 });
47 });
48 });
General Comments 0
You need to be logged in to leave comments. Login now