##// END OF EJS Templates
use wait_for_output util function
use wait_for_output util function

File last commit:

r13294:04e06a5b
r13295:1770835d
Show More
execute_code_cell.js
60 lines | 1.7 KiB | application/javascript | JavascriptLexer
David Wyde
Add CasperJS utility functions, and tests for code and...
r13249 //
// Test code cell execution.
//
Paul Ivanov
pep8 style function names
r13275 casper.notebook_test(function () {
David Wyde
Add CasperJS utility functions, and tests for code and...
r13249 this.evaluate(function () {
Paul Ivanov
consistently get the first cell
r13260 var cell = IPython.notebook.get_cell(0);
Thomas Kluyver
Use Python 3 compatible syntax in tests
r13278 cell.set_text('a=10; print(a)');
David Wyde
Add CasperJS utility functions, and tests for code and...
r13249 cell.execute();
});
Paul Ivanov
wait_for_output utility function
r13294 this.wait_for_output(0);
David Wyde
Add CasperJS utility functions, and tests for code and...
r13249
David Wyde
Wrap CasperJS tests in a helper function to reduce boilerplate.
r13253 this.then(function () {
var result = this.evaluate(function () {
var cell = IPython.notebook.get_cell(0);
Paul Ivanov
less convoluted way of grabbing output
r13259 var output = cell.output_area.outputs[0].text;
David Wyde
Wrap CasperJS tests in a helper function to reduce boilerplate.
r13253 return output;
})
Paul Ivanov
repeat test with keyboard shortcut
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()
Paul Ivanov
utility functions + tests for shift- & ctrl-enter
r13293 IPython.utils.press_ctrl_enter();
Paul Ivanov
repeat test with keyboard shortcut
r13292 });
Paul Ivanov
wait_for_output utility function
r13294 this.wait_for_output(0);
Paul Ivanov
repeat test with keyboard shortcut
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)')
David Wyde
Wrap CasperJS tests in a helper function to reduce boilerplate.
r13253 });
Paul Ivanov
utility functions + tests for shift- & ctrl-enter
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();
});
Paul Ivanov
wait_for_output utility function
r13294 this.wait_for_output(0);
Paul Ivanov
utility functions + tests for shift- & ctrl-enter
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)')
});
David Wyde
Add CasperJS utility functions, and tests for code and...
r13249 });