merge_cells_api.js
43 lines
| 1.3 KiB
| application/javascript
|
JavascriptLexer
David Wyde
|
r13256 | // | ||
// Test merging two notebook cells. | ||||
// | ||||
Paul Ivanov
|
r13275 | casper.notebook_test(function() { | ||
Jonathan Frederic
|
r15941 | var that = this; | ||
Jonathan Frederic
|
r15943 | var set_cells_text = function () { | ||
that.evaluate(function() { | ||||
David Wyde
|
r13256 | var cell_one = IPython.notebook.get_selected_cell(); | ||
cell_one.set_text('a = 5'); | ||||
Jonathan Frederic
|
r15943 | }); | ||
that.trigger_keydown('b'); | ||||
Jonathan Frederic
|
r15941 | |||
Jonathan Frederic
|
r15943 | that.evaluate(function() { | ||
David Wyde
|
r13256 | var cell_two = IPython.notebook.get_selected_cell(); | ||
Thomas Kluyver
|
r13278 | cell_two.set_text('print(a)'); | ||
Jonathan Frederic
|
r15943 | }); | ||
}; | ||||
this.evaluate(function () { | ||||
IPython.notebook.command_mode(); | ||||
}); | ||||
David Wyde
|
r13256 | |||
Jonathan Frederic
|
r15943 | // merge_cell_above() | ||
Jonathan Frederic
|
r15948 | set_cells_text(); | ||
Jonathan Frederic
|
r15943 | var output_above = this.evaluate(function () { | ||
David Wyde
|
r13256 | IPython.notebook.merge_cell_above(); | ||
Jonathan Frederic
|
r15949 | return IPython.notebook.get_selected_cell().get_text(); | ||
Jonathan Frederic
|
r15943 | }); | ||
David Wyde
|
r13256 | |||
Jonathan Frederic
|
r15943 | // merge_cell_below() | ||
Jonathan Frederic
|
r15948 | set_cells_text(); | ||
Jonathan Frederic
|
r15943 | var output_below = this.evaluate(function() { | ||
David Wyde
|
r13256 | IPython.notebook.select(0); | ||
IPython.notebook.merge_cell_below(); | ||||
Jonathan Frederic
|
r15949 | return IPython.notebook.get_selected_cell().get_text(); | ||
David Wyde
|
r13256 | }); | ||
Jonathan Frederic
|
r15943 | this.test.assertEquals(output_above, 'a = 5\nprint(a)', | ||
Brian E. Granger
|
r14081 | 'Successful merge_cell_above().'); | ||
Jonathan Frederic
|
r15943 | this.test.assertEquals(output_below, 'a = 5\nprint(a)', | ||
Brian E. Granger
|
r14081 | 'Successful merge_cell_below().'); | ||
David Wyde
|
r13256 | }); | ||