Moved is_cell_rendered into base

This commit is contained in:
Jonathan Frederic 2014-04-09 12:54:18 -07:00 committed by Jonathan Frederic
parent 359d7342d2
commit edbaff8400
2 changed files with 14 additions and 14 deletions

View File

@ -1,12 +1,6 @@
// Test
casper.notebook_test(function () {
this.is_rendered = function(i) {
return this.evaluate(function(i) {
return !!IPython.notebook.get_cell(i).rendered;
}, {i:i});
};
var a = 'print("a")';
var index = this.append_cell(a);
this.execute_cell_then(index, function(index) {
@ -15,29 +9,29 @@ casper.notebook_test(function () {
this.validate_notebook_state('select ' + index, 'command', index);
this.trigger_keydown('m');
this.test.assertEquals(this.get_cell(index).cell_type, 'markdown', 'm; cell is markdown');
this.test.assert(!this.is_rendered(index), 'm; cell is unrendered');
this.test.assert(!this.is_cell_rendered(index), 'm; cell is unrendered');
this.trigger_keydown('enter');
this.test.assert(!this.is_rendered(index), 'enter; cell is unrendered');
this.test.assert(!this.is_cell_rendered(index), 'enter; cell is unrendered');
this.validate_notebook_state('enter', 'edit', index);
this.trigger_keydown('ctrl-enter');
this.test.assert(this.is_rendered(index), 'ctrl-enter; cell is rendered');
this.test.assert(this.is_cell_rendered(index), 'ctrl-enter; cell is rendered');
this.validate_notebook_state('enter', 'command', index);
this.trigger_keydown('enter');
this.test.assert(!this.is_rendered(index), 'enter; cell is unrendered');
this.test.assert(!this.is_cell_rendered(index), 'enter; cell is unrendered');
this.select_cell(index-1);
this.test.assert(!this.is_rendered(index), 'select ' + (index-1) + '; cell ' + index + ' is still unrendered');
this.test.assert(!this.is_cell_rendered(index), 'select ' + (index-1) + '; cell ' + index + ' is still unrendered');
this.validate_notebook_state('select ' + (index-1), 'command', index-1);
this.select_cell(index);
this.validate_notebook_state('select ' + index, 'command', index);
this.trigger_keydown('ctrl-enter');
this.test.assert(this.is_rendered(index), 'ctrl-enter; cell is rendered');
this.test.assert(this.is_cell_rendered(index), 'ctrl-enter; cell is rendered');
this.select_cell(index-1);
this.validate_notebook_state('select ' + (index-1), 'command', index-1);
this.trigger_keydown('shift-enter');
this.validate_notebook_state('shift-enter', 'command', index);
this.test.assert(this.is_rendered(index), 'shift-enter; cell is rendered');
this.test.assert(this.is_cell_rendered(index), 'shift-enter; cell is rendered');
this.trigger_keydown('shift-enter'); // Creates one cell
this.validate_notebook_state('shift-enter', 'edit', index+1);
this.test.assert(this.is_rendered(index), 'shift-enter; cell is rendered');
this.test.assert(this.is_cell_rendered(index), 'shift-enter; cell is rendered');
});
});

View File

@ -417,6 +417,12 @@ casper.cell_has_class = function(index, classes) {
}, {i : index, c: classes});
};
casper.is_cell_rendered = function (index, msg) {
return this.evaluate(function(i) {
return !!IPython.notebook.get_cell(i).rendered;
}, {i:i});
};
casper.assert_colors_equal = function (hex_color, local_color, msg) {
// Tests to see if two colors are equal.
//