From 1865d079284519b95bae7a570cedadef48ddd13a Mon Sep 17 00:00:00 2001 From: Jonathan Frederic Date: Wed, 4 Dec 2013 23:34:48 +0000 Subject: [PATCH] Added bool widget value toggle tests --- .../html/tests/casperjs/test_cases/widgets.js | 43 ++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/IPython/html/tests/casperjs/test_cases/widgets.js b/IPython/html/tests/casperjs/test_cases/widgets.js index d6c244dc6..04ac55003 100644 --- a/IPython/html/tests/casperjs/test_cases/widgets.js +++ b/IPython/html/tests/casperjs/test_cases/widgets.js @@ -100,7 +100,7 @@ casper.notebook_test(function () { 'Checkbox exists.'); 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.'); 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 ////////////////////////////////////////////////////// var button_index = this.append_cell( 'button = widgets.ButtonWidget(description="Title")\n' +