widget_string.js
59 lines
| 2.5 KiB
| application/javascript
|
JavascriptLexer
Jonathan Frederic
|
r14464 | // Test widget string class | ||
casper.notebook_test(function () { | ||||
Jonathan Frederic
|
r18910 | var string_index = this.append_cell( | ||
Jonathan Frederic
|
r14464 | 'from IPython.html import widgets\n' + | ||
'from IPython.display import display, clear_output\n' + | ||||
Jonathan Frederic
|
r17598 | 'string_widget = [widgets.Text(value = "xyz", placeholder = "abc"),\n' + | ||
' widgets.Textarea(value = "xyz", placeholder = "def"),\n' + | ||||
' widgets.HTML(value = "xyz"),\n' + | ||||
' widgets.Latex(value = "$\\\\LaTeX{}$")]\n' + | ||||
Jonathan Frederic
|
r14583 | '[display(widget) for widget in string_widget]\n'+ | ||
Jonathan Frederic
|
r14464 | 'print("Success")'); | ||
this.execute_cell_then(string_index, function(index){ | ||||
MinRK
|
r14797 | this.test.assertEquals(this.get_output_cell(index).text, 'Success\n', | ||
Jonathan Frederic
|
r14464 | 'Create string widget cell executed with correct output.'); | ||
Jonathan Frederic
|
r18910 | }); | ||
// Wait for the widget to actually display. | ||||
var textbox_selector = '.widget-area .widget-subarea .widget-hbox input[type=text]'; | ||||
var textarea_selector = '.widget-area .widget-subarea .widget-hbox textarea'; | ||||
var latex_selector = '.widget-area .widget-subarea div span.MathJax_Preview'; | ||||
this.wait_for_element(string_index, textbox_selector); | ||||
this.wait_for_element(string_index, textarea_selector); | ||||
this.wait_for_element(string_index, latex_selector); | ||||
Jonathan Frederic
|
r14464 | |||
Jonathan Frederic
|
r18910 | // Continue with the tests. | ||
this.then(function(){ | ||||
this.test.assert(this.cell_element_exists(string_index, | ||||
Jonathan Frederic
|
r14464 | '.widget-area .widget-subarea'), | ||
'Widget subarea exists.'); | ||||
Jonathan Frederic
|
r18910 | this.test.assert(this.cell_element_exists(string_index, | ||
textbox_selector), | ||||
Jonathan Frederic
|
r14464 | 'Textbox exists.'); | ||
Jonathan Frederic
|
r18910 | this.test.assert(this.cell_element_exists(string_index, | ||
textarea_selector), | ||||
Jonathan Frederic
|
r14464 | 'Textarea exists.'); | ||
Jonathan Frederic
|
r18910 | this.test.assert(this.cell_element_function(string_index, | ||
textarea_selector, 'val')=='xyz', | ||||
Jonathan Frederic
|
r14464 | 'Python set textarea value.'); | ||
Jonathan Frederic
|
r18910 | this.test.assert(this.cell_element_function(string_index, | ||
textbox_selector, 'val')=='xyz', | ||||
Jonathan Frederic
|
r14464 | 'Python set textbox value.'); | ||
this.test.assert(this.cell_element_exists(string_index, | ||||
Jonathan Frederic
|
r18910 | latex_selector), | ||
Jonathan Frederic
|
r14464 | 'MathJax parsed the LaTeX successfully.'); | ||
Jessica B. Hamrick
|
r16344 | |||
Jonathan Frederic
|
r18910 | this.test.assert(this.cell_element_function(string_index, | ||
textarea_selector, 'attr', ['placeholder'])=='def', | ||||
Jessica B. Hamrick
|
r16344 | 'Python set textarea placeholder.'); | ||
Jonathan Frederic
|
r18910 | this.test.assert(this.cell_element_function(string_index, | ||
textbox_selector, 'attr', ['placeholder'])=='abc', | ||||
Jessica B. Hamrick
|
r16344 | 'Python set textbox placehoder.'); | ||
Jonathan Frederic
|
r14464 | }); | ||
Jessica B. Hamrick
|
r16344 | }); | ||