From baf90fd7555558d71f39ff30e302b37a227ae310 Mon Sep 17 00:00:00 2001 From: Paul Ivanov Date: Tue, 22 Oct 2013 12:05:07 -0700 Subject: [PATCH] add checks for new cell added using shift-enter --- .../tests/casperjs/test_cases/execute_code_cell.js | 14 +++++++++----- IPython/html/tests/casperjs/util.js | 8 ++++++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/IPython/html/tests/casperjs/test_cases/execute_code_cell.js b/IPython/html/tests/casperjs/test_cases/execute_code_cell.js index 16203a07d..4860fcd63 100644 --- a/IPython/html/tests/casperjs/test_cases/execute_code_cell.js +++ b/IPython/html/tests/casperjs/test_cases/execute_code_cell.js @@ -13,7 +13,7 @@ casper.notebook_test(function () { // refactor this into just a get_output(0) this.then(function () { var result = this.get_output_cell(0); - this.test.assertEquals(result.text, '10\n', 'cell execute (using js)') + this.test.assertEquals(result.text, '10\n', 'cell execute (using js)'); }); @@ -21,7 +21,7 @@ casper.notebook_test(function () { this.thenEvaluate(function () { var cell = IPython.notebook.get_cell(0); cell.set_text('a=11; print(a)'); - cell.clear_output() + cell.clear_output(); IPython.utils.press_ctrl_enter(); }); @@ -29,14 +29,16 @@ casper.notebook_test(function () { this.then(function () { var result = this.get_output_cell(0); - this.test.assertEquals(result.text, '11\n', 'cell execute (using ctrl-enter)') + var num_cells = this.get_cells_length(); + this.test.assertEquals(result.text, '11\n', 'cell execute (using ctrl-enter)'); + this.test.assertEquals(num_cells, 1, ' ^--- does not add a new cell') }); // do it again with the keyboard shortcut this.thenEvaluate(function () { var cell = IPython.notebook.get_cell(0); cell.set_text('a=12; print(a)'); - cell.clear_output() + cell.clear_output(); IPython.utils.press_shift_enter(); }); @@ -44,6 +46,8 @@ casper.notebook_test(function () { this.then(function () { var result = this.get_output_cell(0); - this.test.assertEquals(result.text, '12\n', 'cell execute (using shift-enter)') + var num_cells = this.get_cells_length(); + this.test.assertEquals(result.text, '12\n', 'cell execute (using shift-enter)'); + this.test.assertEquals(num_cells, 2, ' ^--- adds a new cell') }); }); diff --git a/IPython/html/tests/casperjs/util.js b/IPython/html/tests/casperjs/util.js index b3ca35797..5ee622562 100644 --- a/IPython/html/tests/casperjs/util.js +++ b/IPython/html/tests/casperjs/util.js @@ -78,6 +78,14 @@ casper.get_output_cell = function (cell_num) { return result; }; +// return the number of cells in the notebook +casper.get_cells_length = function () { + var result = casper.evaluate(function () { + return IPython.notebook.get_cells().length; + }) + return result; +}; + // Wrap a notebook test to reduce boilerplate. casper.notebook_test = function(test) { this.open_new_notebook();