notebook/IPython/html/tests/widgets/widget_container.js

80 lines
3.0 KiB
JavaScript
Raw Normal View History

2013-12-13 02:49:34 +08:00
// Test container class
casper.notebook_test(function () {
index = this.append_cell(
'from IPython.html import widgets\n' +
'from IPython.display import display, clear_output\n' +
'print("Success")');
this.execute_cell_then(index);
var container_index = this.append_cell(
2014-08-14 04:19:27 +08:00
'container = widgets.Box()\n' +
'button = widgets.Button()\n'+
'container.children = [button]\n'+
2013-12-13 02:49:34 +08:00
'display(container)\n'+
'container.add_class("my-test-class")\n'+
'print("Success")\n');
this.execute_cell_then(container_index, function(index){
2014-01-27 09:01:59 +08:00
this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
2013-12-13 02:49:34 +08:00
'Create container cell executed with correct output.');
this.test.assert(this.cell_element_exists(index,
'.widget-area .widget-subarea'),
'Widget subarea exists.');
this.test.assert(this.cell_element_exists(index,
'.widget-area .widget-subarea .widget-container'),
'Widget container exists.');
this.test.assert(this.cell_element_exists(index,
'.widget-area .widget-subarea .my-test-class'),
'add_class works.');
this.test.assert(this.cell_element_exists(index,
'.widget-area .widget-subarea .my-test-class button'),
'Container parent/child relationship works.');
});
index = this.append_cell(
'container.set_css("float", "right")\n'+
2013-12-13 02:49:34 +08:00
'print("Success")\n');
this.execute_cell_then(index, function(index){
2014-01-27 09:01:59 +08:00
this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
2013-12-13 02:49:34 +08:00
'Set container class CSS cell executed with correct output.');
2013-12-13 02:49:34 +08:00
this.test.assert(this.cell_element_function(container_index,
'.widget-area .widget-subarea .my-test-class', 'css', ['float'])=='right',
2013-12-13 02:49:34 +08:00
'set_css works.');
});
index = this.append_cell(
'container.remove_class("my-test-class")\n'+
'print("Success")\n');
this.execute_cell_then(index, function(index){
2014-01-27 09:01:59 +08:00
this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
2013-12-13 02:49:34 +08:00
'Remove container class cell executed with correct output.');
this.test.assert(! this.cell_element_exists(container_index,
'.widget-area .widget-subarea .my-test-class'),
'remove_class works.');
});
index = this.append_cell(
'display(button)\n'+
'print("Success")\n');
this.execute_cell_then(index, function(index){
2014-01-27 09:01:59 +08:00
this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
2013-12-13 02:49:34 +08:00
'Display container child executed with correct output.');
this.test.assert(! this.cell_element_exists(index,
'.widget-area .widget-subarea .widget-container'),
'Parent container not displayed.');
this.test.assert(this.cell_element_exists(index,
'.widget-area .widget-subarea button'),
'Child displayed.');
});
});