##// END OF EJS Templates
refactor to improve cell switching in edit mode...
refactor to improve cell switching in edit mode This code was repeated in both CodeCell and TextCell, both of which are extensions of Cell, so this just unifies the logic in Cell. TextCell had logic here to check if the cell was rendered or not, but I don't believe it is possible to end up triggering such a code path. (Should that be required, I can always just add back these methods to TextCell, performing the .rendered==True check, and calling the Cell prior to this, code mirror at_top would only return true on if the cursor was at the first character of the top line. Now, pressing up arrow on any character on the top line will take you to the cell above. The same applies for the bottom line. Pressing down arrow would only go to the next cell if the cursor was at a location *after* the last character (something that is only possible to achieve in vim mode if the last line is empty, for example). Now, down arrow on any character of the last line will go to the next cell.

File last commit:

r15201:029ac024
r15754:d60e793e
Show More
widget_bool.js
85 lines | 3.6 KiB | application/javascript | JavascriptLexer
// Test widget bool 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 bool_index = this.append_cell(
'bool_widgets = [widgets.CheckboxWidget(description="Title", value=True),\n' +
' widgets.ToggleButtonWidget(description="Title", value=True)]\n' +
'display(bool_widgets[0])\n' +
'display(bool_widgets[1])\n' +
'print("Success")');
this.execute_cell_then(bool_index, function(index){
this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
'Create bool 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'),
'Checkbox exists.');
this.test.assert(this.cell_element_function(index,
'.widget-area .widget-subarea .widget-hbox-single input', 'prop', ['checked']),
'Checkbox is checked.');
this.test.assert(this.cell_element_exists(index,
'.widget-area .widget-subarea .widget-hbox-single .widget-hlabel'),
'Checkbox label exists.');
this.test.assert(this.cell_element_function(index,
'.widget-area .widget-subarea .widget-hbox-single .widget-hlabel', 'html')=="Title",
'Checkbox labeled correctly.');
this.test.assert(this.cell_element_exists(index,
'.widget-area .widget-subarea button'),
'Toggle button exists.');
this.test.assert(this.cell_element_function(index,
'.widget-area .widget-subarea button', 'html')=="Title",
'Toggle button labeled correctly.');
this.test.assert(this.cell_element_function(index,
'.widget-area .widget-subarea button', 'hasClass', ['active']),
'Toggle button is toggled.');
});
index = this.append_cell(
'bool_widgets[0].value = False\n' +
'bool_widgets[1].value = False\n' +
'print("Success")');
this.execute_cell_then(index, function(index){
this.test.assertEquals(this.get_output_cell(index).text, '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 button', 'hasClass', ['active']),
'Toggle button is not toggled. (1)');
// 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 checked. (2)');
// Try toggling the bool by clicking on the toggle button.
this.cell_element_function(bool_index, '.widget-area .widget-subarea button', 'click');
this.test.assert(this.cell_element_function(bool_index,
'.widget-area .widget-subarea button', 'hasClass', ['active']),
'Toggle button is toggled. (3)');
});
});