##// END OF EJS Templates
Adding prompt area to non-CodeCells to indent content....
Adding prompt area to non-CodeCells to indent content. This is a reponse to the problem of having really long lines in Markdown cells, which makes the content difficult to read. Users want wide code cells, so we don't want to narrow everything. The solution here is to give a prompt area to the heading/md cells to narrow their content area slightly. The only problem is that this makes it more difficult to distinguish between output and md content that follows that output. The solve this, we are adding a narrow line between output and following md.

File last commit:

r13301:b4a7925b
r13776:e285883b
Show More
execute_code_cell.js
69 lines | 2.1 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
Paul Ivanov
refactor of get_output_cell
r13299 // refactor this into just a get_output(0)
David Wyde
Wrap CasperJS tests in a helper function to reduce boilerplate.
r13253 this.then(function () {
Paul Ivanov
refactor of get_output_cell
r13299 var result = this.get_output_cell(0);
Paul Ivanov
add checks for new cell added using shift-enter
r13300 this.test.assertEquals(result.text, '10\n', 'cell execute (using js)');
Paul Ivanov
repeat test with keyboard shortcut
r13292 });
// do it again with the keyboard shortcut
this.thenEvaluate(function () {
var cell = IPython.notebook.get_cell(0);
cell.set_text('a=11; print(a)');
Paul Ivanov
add checks for new cell added using shift-enter
r13300 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 () {
Paul Ivanov
refactor of get_output_cell
r13299 var result = this.get_output_cell(0);
Paul Ivanov
add checks for new cell added using shift-enter
r13300 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')
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)');
Paul Ivanov
add checks for new cell added using shift-enter
r13300 cell.clear_output();
Paul Ivanov
utility functions + tests for shift- & ctrl-enter
r13293 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 () {
Paul Ivanov
refactor of get_output_cell
r13299 var result = this.get_output_cell(0);
Paul Ivanov
add checks for new cell added using shift-enter
r13300 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')
Paul Ivanov
utility functions + tests for shift- & ctrl-enter
r13293 });
Paul Ivanov
adds test of clicking the play button
r13301
// press the "play" triangle button in the toolbar
this.thenEvaluate(function () {
var cell = IPython.notebook.get_cell(0);
IPython.notebook.select(0);
cell.clear_output();
cell.set_text('a=13; print(a)');
$('#run_b').click();
});
this.wait_for_output(0);
this.then(function () {
var result = this.get_output_cell(0);
this.test.assertEquals(result.text, '13\n', 'cell execute (using "play" toolbar button)')
});
David Wyde
Add CasperJS utility functions, and tests for code and...
r13249 });