From 134351a744b7e81955de33f0897e5bb4e0e68de2 Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Tue, 8 Dec 2015 17:14:39 +0100 Subject: [PATCH] Fist and test past_cell_replace with multi-selection closes #792 --- notebook/static/notebook/js/notebook.js | 2 +- notebook/tests/notebook/dualmode_clipboard.js | 39 ++++++++++++++++++- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/notebook/static/notebook/js/notebook.js b/notebook/static/notebook/js/notebook.js index 14c8b42aa..fbf168544 100644 --- a/notebook/static/notebook/js/notebook.js +++ b/notebook/static/notebook/js/notebook.js @@ -1383,7 +1383,7 @@ define(function (require) { if (this.clipboard !== null && this.paste_enabled) { var first_inserted = null; for (var i=0; i < this.clipboard.length; i++) { - var cell_data = this.clipboard; + var cell_data = this.clipboard[i]; var new_cell = this.insert_cell_above(cell_data.cell_type); new_cell.fromJSON(cell_data); if (first_inserted === null) { diff --git a/notebook/tests/notebook/dualmode_clipboard.js b/notebook/tests/notebook/dualmode_clipboard.js index 5068c49c6..f3825249a 100644 --- a/notebook/tests/notebook/dualmode_clipboard.js +++ b/notebook/tests/notebook/dualmode_clipboard.js @@ -52,4 +52,41 @@ casper.notebook_test(function () { this.test.assertEquals(this.get_cell_text(0), c, 'Verify that cell 0 has the copied contents.'); this.test.assertEquals(this.get_cells_length(), num_cells+3, 'Verify a the cell was added.'); }); -}); \ No newline at end of file +}); + + +casper.notebook_test(function () { + this.append_cell('1'); + this.append_cell('2'); + this.append_cell('3'); + this.append_cell('a'); + this.append_cell('b'); + this.append_cell('c'); + + + this.then(function () { + // Copy/paste/cut + var num_cells = this.get_cells_length(); + this.test.assertEquals(this.get_cell_text(1), '1', 'Verify that cell 1 is a'); + this.select_cell(1); + this.select_cell(3, false); + + this.trigger_keydown('c'); // Copy + + this.select_cell(5) + + this.evaluate(function () { + $("#past_cell_replace").click(); + }); + + this.validate_notebook_state('x', 'command', 1); + var expected_state = ['','1','2','3', 'a', '1', '2', '3', 'c']; + + for (var i=1; i