Actually test that the j-nth cell.

This commit is contained in:
Matthias Bussonnier 2014-12-23 22:29:51 +01:00
parent 9c959ce6b1
commit b003b62de4

View File

@ -394,7 +394,7 @@ casper.validate_notebook_state = function(message, mode, cell_index) {
if (cell_index!==undefined) {
// Is the specified cell the only cell in edit mode?
this.test.assert(this.is_only_cell_edit(cell_index),
message + '; cell ' + cell_index + ' is the only cell in edit mode');
message + '; cell ' + cell_index + ' is the only cell in edit mode '+ this.cells_modes());
// Is the specified cell the only cell with a focused code mirror?
this.test.assert(this.is_cell_editor_focused(cell_index),
message + '; cell ' + cell_index + '\'s editor is appropriately focused');
@ -508,11 +508,11 @@ casper.is_only_cell_edit = function(index) {
var cells_length = this.get_cells_length();
for (var j = 0; j < cells_length; j++) {
if (j === index) {
if (!this.cell_mode_is('edit')) {
if (!this.cell_mode_is(j, 'edit')) {
return false;
}
} else {
if (this.cell_mode_is('edit')) {
if (this.cell_mode_is(j, 'edit')) {
return false;
}
}
@ -539,6 +539,11 @@ casper.is_only_cell_on = function(i, on_class, off_class) {
return true;
};
casper.cells_modes = function(){
return this.evaluate(function(){
return IPython.notebook.get_cells().map(function(x,c){return x.mode})
}, {});
};
casper.cell_mode_is = function(index, mode) {
// Check if a cell is in a specific mode