widget_box.js
91 lines
| 3.5 KiB
| application/javascript
|
JavascriptLexer
Jonathan Frederic
|
r14464 | // Test container class | |
casper.notebook_test(function () { | |||
Jonathan Frederic
|
r18910 | // Create a box widget. | |
Jonathan Frederic
|
r14464 | var container_index = this.append_cell( | |
Jonathan Frederic
|
r18910 | 'from IPython.html import widgets\n' + | |
'from IPython.display import display, clear_output\n' + | |||
Jonathan Frederic
|
r17637 | 'container = widgets.Box()\n' + | |
Jonathan Frederic
|
r17598 | 'button = widgets.Button()\n'+ | |
Jonathan Frederic
|
r14509 | 'container.children = [button]\n'+ | |
Jonathan Frederic
|
r14464 | 'display(container)\n'+ | |
Jonathan Frederic
|
r17721 | 'container._dom_classes = ["my-test-class"]\n'+ | |
Jonathan Frederic
|
r14464 | 'print("Success")\n'); | |
this.execute_cell_then(container_index, function(index){ | |||
MinRK
|
r14797 | this.test.assertEquals(this.get_output_cell(index).text, 'Success\n', | |
Jonathan Frederic
|
r14464 | 'Create container cell executed with correct output.'); | |
Jonathan Frederic
|
r18910 | }); | |
Jonathan Frederic
|
r14464 | ||
Jonathan Frederic
|
r18910 | // Wait for the widgets to actually display. | |
var widget_box_selector = '.widget-area .widget-subarea .widget-box'; | |||
var widget_box_button_selector = '.widget-area .widget-subarea .widget-box button'; | |||
this.wait_for_element(container_index, widget_box_selector); | |||
this.wait_for_element(container_index, widget_box_button_selector); | |||
// Continue with the tests. | |||
this.then(function() { | |||
this.test.assert(this.cell_element_exists(container_index, | |||
Jonathan Frederic
|
r14464 | '.widget-area .widget-subarea'), | |
'Widget subarea exists.'); | |||
Jonathan Frederic
|
r18910 | this.test.assert(this.cell_element_exists(container_index, | |
widget_box_selector), | |||
Jonathan Frederic
|
r14464 | 'Widget container exists.'); | |
Jonathan Frederic
|
r18910 | this.test.assert(this.cell_element_exists(container_index, | |
Jonathan Frederic
|
r14464 | '.widget-area .widget-subarea .my-test-class'), | |
Jonathan Frederic
|
r17721 | '_dom_classes works.'); | |
Jonathan Frederic
|
r14464 | ||
Jonathan Frederic
|
r18910 | this.test.assert(this.cell_element_exists(container_index, | |
widget_box_button_selector), | |||
Jonathan Frederic
|
r14464 | 'Container parent/child relationship works.'); | |
}); | |||
index = this.append_cell( | |||
Jonathan Frederic
|
r17731 | 'container.box_style = "success"\n'+ | |
Jonathan Frederic
|
r14464 | 'print("Success")\n'); | |
this.execute_cell_then(index, function(index){ | |||
MinRK
|
r14797 | this.test.assertEquals(this.get_output_cell(index).text, 'Success\n', | |
Jonathan Frederic
|
r17731 | 'Set box_style cell executed with correct output.'); | |
this.test.assert(this.cell_element_exists(container_index, | |||
'.widget-box.alert-success'), | |||
'Set box_style works.'); | |||
Jonathan Frederic
|
r14464 | }); | |
index = this.append_cell( | |||
Jonathan Frederic
|
r17721 | 'container._dom_classes = []\n'+ | |
Jonathan Frederic
|
r14464 | 'print("Success")\n'); | |
this.execute_cell_then(index, function(index){ | |||
MinRK
|
r14797 | this.test.assertEquals(this.get_output_cell(index).text, 'Success\n', | |
Jonathan Frederic
|
r14464 | 'Remove container class cell executed with correct output.'); | |
this.test.assert(! this.cell_element_exists(container_index, | |||
'.widget-area .widget-subarea .my-test-class'), | |||
Jonathan Frederic
|
r17721 | '_dom_classes can be used to remove a class.'); | |
Jonathan Frederic
|
r14464 | }); | |
Jonathan Frederic
|
r18910 | var boxalone_index = this.append_cell( | |
Jonathan Frederic
|
r14464 | 'display(button)\n'+ | |
'print("Success")\n'); | |||
Jonathan Frederic
|
r18910 | this.execute_cell_then(boxalone_index, function(index){ | |
MinRK
|
r14797 | this.test.assertEquals(this.get_output_cell(index).text, 'Success\n', | |
Jonathan Frederic
|
r14464 | 'Display container child executed with correct output.'); | |
Jonathan Frederic
|
r18910 | }); | |
// Wait for the widget to actually display. | |||
var widget_button_selector = '.widget-area .widget-subarea button'; | |||
this.wait_for_element(boxalone_index, widget_button_selector); | |||
Jonathan Frederic
|
r14464 | ||
Jonathan Frederic
|
r18910 | // Continue with the tests. | |
this.then(function() { | |||
this.test.assert(! this.cell_element_exists(boxalone_index, | |||
widget_box_selector), | |||
Jonathan Frederic
|
r14464 | 'Parent container not displayed.'); | |
Jonathan Frederic
|
r18910 | this.test.assert(this.cell_element_exists(boxalone_index, | |
widget_button_selector), | |||
Jonathan Frederic
|
r14464 | 'Child displayed.'); | |
}); | |||
}); |