add tests for cell_type preserving insertion

This commit is contained in:
Paul Ivanov 2014-05-20 18:53:32 -07:00
parent 7778aed8a8
commit 9631028c1e
2 changed files with 16 additions and 3 deletions

View File

@ -18,10 +18,25 @@ casper.notebook_test(function () {
this.select_cell(2);
this.trigger_keydown('a'); // Creates one cell
this.test.assertEquals(this.get_cell_text(2), '', 'a; New cell 2 text is empty');
this.test.assertEquals(this.get_cell(2).cell_type, 'code', 'a; inserts a code cell when on code cell');
this.validate_notebook_state('a', 'command', 2);
this.trigger_keydown('b'); // Creates one cell
this.test.assertEquals(this.get_cell_text(2), '', 'b; Cell 2 text is still empty');
this.test.assertEquals(this.get_cell_text(3), '', 'b; New cell 3 text is empty');
this.test.assertEquals(this.get_cell(3).cell_type, 'code', 'b; inserts a code cell when on code cell');
this.validate_notebook_state('b', 'command', 3);
});
});
this.then(function () {
// Cell insertion
this.select_cell(2);
this.trigger_keydown('m'); // switch it to markdown for the next test
this.trigger_keydown('a'); // Creates one cell
this.test.assertEquals(this.get_cell_text(2), '', 'a; New cell 2 text is empty');
this.test.assertEquals(this.get_cell(2).cell_type, 'markdown', 'a; inserts a markdown cell when on markdown cell');
this.validate_notebook_state('a', 'command', 2);
this.trigger_keydown('b'); // Creates one cell
this.test.assertEquals(this.get_cell_text(2), '', 'b; Cell 2 text is still empty');
this.test.assertEquals(this.get_cell(3).cell_type, 'markdown', 'b; inserts a markdown cell when on markdown cell');
this.validate_notebook_state('b', 'command', 3);
});
});

View File

@ -167,8 +167,6 @@ casper.get_cell_text = function(index){
casper.insert_cell_at_bottom = function(cell_type){
// Inserts a cell at the bottom of the notebook
// Returns the new cell's index.
cell_type = cell_type || 'code';
return this.evaluate(function (cell_type) {
var cell = IPython.notebook.insert_cell_at_bottom(cell_type);
return IPython.notebook.find_cell_index(cell);