execute_code_cell.js
60 lines
| 1.7 KiB
| application/javascript
|
JavascriptLexer
|
r13249 | // | ||
// Test code cell execution. | ||||
// | ||||
|
r13275 | casper.notebook_test(function () { | ||
|
r13249 | this.evaluate(function () { | ||
|
r13260 | var cell = IPython.notebook.get_cell(0); | ||
|
r13278 | cell.set_text('a=10; print(a)'); | ||
|
r13249 | cell.execute(); | ||
}); | ||||
|
r13294 | this.wait_for_output(0); | ||
|
r13249 | |||
|
r13253 | this.then(function () { | ||
var result = this.evaluate(function () { | ||||
var cell = IPython.notebook.get_cell(0); | ||||
|
r13259 | var output = cell.output_area.outputs[0].text; | ||
|
r13253 | return output; | ||
}) | ||||
|
r13292 | this.test.assertEquals(result, '10\n', 'cell execute (using js)') | ||
}); | ||||
// do it again with the keyboard shortcut | ||||
this.thenEvaluate(function () { | ||||
var cell = IPython.notebook.get_cell(0); | ||||
cell.set_text('a=11; print(a)'); | ||||
cell.clear_output() | ||||
|
r13293 | IPython.utils.press_ctrl_enter(); | ||
|
r13292 | }); | ||
|
r13294 | this.wait_for_output(0); | ||
|
r13292 | |||
this.then(function () { | ||||
var result = this.evaluate(function () { | ||||
var cell = IPython.notebook.get_cell(0); | ||||
var output = cell.output_area.outputs[0].text; | ||||
return output; | ||||
}) | ||||
this.test.assertEquals(result, '11\n', 'cell execute (using ctrl-enter)') | ||||
|
r13253 | }); | ||
|
r13293 | |||
// 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() | ||||
IPython.utils.press_shift_enter(); | ||||
}); | ||||
|
r13294 | this.wait_for_output(0); | ||
|
r13293 | |||
this.then(function () { | ||||
var result = this.evaluate(function () { | ||||
var cell = IPython.notebook.get_cell(0); | ||||
var output = cell.output_area.outputs[0].text; | ||||
return output; | ||||
}) | ||||
this.test.assertEquals(result, '12\n', 'cell execute (using shift-enter)') | ||||
}); | ||||
|
r13249 | }); | ||