From 69edadade1e74310100002ae1f39cfe02fe37288 2014-01-16 10:57:08 From: Jonathan Frederic Date: 2014-01-16 10:57:08 Subject: [PATCH] Added StringWidget tests --- diff --git a/IPython/html/tests/casperjs/test_cases/widgets.js b/IPython/html/tests/casperjs/test_cases/widgets.js index 866a8fb..2e06d48 100644 --- a/IPython/html/tests/casperjs/test_cases/widgets.js +++ b/IPython/html/tests/casperjs/test_cases/widgets.js @@ -820,4 +820,66 @@ casper.notebook_test(function () { this.test.assert(verify_selection(this, 4), 'Item added to selection widget.'); }); + // Test string widget ////////////////////////////////////////////////////// + var string_index = this.append_cell( + 'string_widget = widgets.StringWidget()\n' + + 'display(string_widget)\n'+ + 'display(string_widget, view_name="TextAreaView")\n' + + 'display(string_widget, view_name="HTMLView")\n' + + 'display(string_widget, view_name="LatexView")\n' + + 'string_widget.value = "xyz"\n' + + 'print("Success")'); + this.execute_cell_then(string_index, function(index){ + + this.test.assert(this.get_output_cell(index).text == 'Success\n', + 'Create string widget 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-hbox-single input[type=text]'), + 'Textbox exists.'); + + this.test.assert(this.cell_element_exists(index, + '.widget-area .widget-subarea .widget-hbox textarea'), + 'Textarea exists.'); + + this.test.assert(this.cell_element_function(index, + '.widget-area .widget-subarea .widget-hbox textarea', 'val')=='xyz', + 'Python set textarea value.'); + + this.test.assert(this.cell_element_function(index, + '.widget-area .widget-subarea .widget-hbox-single input[type=text]', 'val')=='xyz', + 'Python set textbox value.'); + + this.cell_element_function(index, + '.widget-area .widget-subarea .widget-hbox-single input[type=text]', 'val', ['']) + this.sendKeys('.widget-area .widget-subarea .widget-hbox-single input[type=text]', 'abc'); + + this.test.assert(this.cell_element_function(index, + '.widget-area .widget-subarea .widget-hbox textarea', 'val')=='abc', + 'Textarea updated to textbox contents.'); + + this.cell_element_function(index, + '.widget-area .widget-subarea .widget-hbox textarea', 'val', ['']); + this.sendKeys('.widget-area .widget-subarea .widget-hbox textarea', '$\\LaTeX{}$'); + + this.test.assert(this.cell_element_function(index, + '.widget-area .widget-subarea .widget-hbox-single input[type=text]', 'val')=='$\\LaTeX{}$', + 'Textbox updated to textarea contents.'); + }); + + this.wait(500); // Wait for change to execute in kernel + + index = this.append_cell('print(string_widget.value)'); + this.execute_cell_then(index, function(index){ + this.test.assert(this.get_output_cell(index).text == '$\\LaTeX{}$\n', + 'Python updated with correct string widget value.'); + + this.test.assert(this.cell_element_exists(string_index, + '.widget-area .widget-subarea div span.MathJax_Preview'), + 'MathJax parsed the LaTeX successfully.'); + }); });