Added bool widget value toggle tests

This commit is contained in:
Jonathan Frederic 2013-12-04 23:34:48 +00:00
parent 9a15dca291
commit 1865d07928

View File

@ -100,7 +100,7 @@ casper.notebook_test(function () {
'Checkbox exists.'); 'Checkbox exists.');
this.test.assert(this.cell_element_function(index, this.test.assert(this.cell_element_function(index,
'.widget-area .widget-subarea .widget-hbox-single input', 'val')==true, '.widget-area .widget-subarea .widget-hbox-single input', 'prop', ['checked']),
'Checkbox is checked.'); 'Checkbox is checked.');
this.test.assert(this.cell_element_exists(index, this.test.assert(this.cell_element_exists(index,
@ -125,6 +125,47 @@ casper.notebook_test(function () {
}); });
index = this.append_cell(
'bool_widget.value = False\n' +
'print("Success")');
this.execute_cell_then(index, function(index){
var button_output = this.get_output_cell(index).text;
this.test.assert(button_output == 'Success\n',
'Change bool widget value cell executed with correct output.');
this.test.assert(!this.cell_element_function(bool_index,
'.widget-area .widget-subarea .widget-hbox-single input', 'prop', ['checked']),
'Checkbox is not checked. (1)');
this.test.assert(!this.cell_element_function(bool_index,
'.widget-area .widget-subarea div button', 'hasClass', ['active']),
'Toggle button is not toggled. (1)');
// Try toggling the bool by clicking on the toggle button.
this.cell_element_function(bool_index, '.widget-area .widget-subarea div button', 'click');
this.test.assert(this.cell_element_function(bool_index,
'.widget-area .widget-subarea .widget-hbox-single input', 'prop', ['checked']),
'Checkbox is checked. (2)');
this.test.assert(this.cell_element_function(bool_index,
'.widget-area .widget-subarea div button', 'hasClass', ['active']),
'Toggle button is toggled. (2)');
// Try toggling the bool by clicking on the checkbox.
this.cell_element_function(bool_index, '.widget-area .widget-subarea .widget-hbox-single input', 'click');
this.test.assert(!this.cell_element_function(bool_index,
'.widget-area .widget-subarea .widget-hbox-single input', 'prop', ['checked']),
'Checkbox is not checked. (3)');
this.test.assert(!this.cell_element_function(bool_index,
'.widget-area .widget-subarea div button', 'hasClass', ['active']),
'Toggle button is not toggled. (3)');
});
// Test button widget ////////////////////////////////////////////////////// // Test button widget //////////////////////////////////////////////////////
var button_index = this.append_cell( var button_index = this.append_cell(
'button = widgets.ButtonWidget(description="Title")\n' + 'button = widgets.ButtonWidget(description="Title")\n' +