##// END OF EJS Templates
add checks for new cell added using shift-enter
Paul Ivanov -
Show More
@@ -13,7 +13,7 casper.notebook_test(function () {
13 // refactor this into just a get_output(0)
13 // refactor this into just a get_output(0)
14 this.then(function () {
14 this.then(function () {
15 var result = this.get_output_cell(0);
15 var result = this.get_output_cell(0);
16 this.test.assertEquals(result.text, '10\n', 'cell execute (using js)')
16 this.test.assertEquals(result.text, '10\n', 'cell execute (using js)');
17 });
17 });
18
18
19
19
@@ -21,7 +21,7 casper.notebook_test(function () {
21 this.thenEvaluate(function () {
21 this.thenEvaluate(function () {
22 var cell = IPython.notebook.get_cell(0);
22 var cell = IPython.notebook.get_cell(0);
23 cell.set_text('a=11; print(a)');
23 cell.set_text('a=11; print(a)');
24 cell.clear_output()
24 cell.clear_output();
25 IPython.utils.press_ctrl_enter();
25 IPython.utils.press_ctrl_enter();
26 });
26 });
27
27
@@ -29,14 +29,16 casper.notebook_test(function () {
29
29
30 this.then(function () {
30 this.then(function () {
31 var result = this.get_output_cell(0);
31 var result = this.get_output_cell(0);
32 this.test.assertEquals(result.text, '11\n', 'cell execute (using ctrl-enter)')
32 var num_cells = this.get_cells_length();
33 this.test.assertEquals(result.text, '11\n', 'cell execute (using ctrl-enter)');
34 this.test.assertEquals(num_cells, 1, ' ^--- does not add a new cell')
33 });
35 });
34
36
35 // do it again with the keyboard shortcut
37 // do it again with the keyboard shortcut
36 this.thenEvaluate(function () {
38 this.thenEvaluate(function () {
37 var cell = IPython.notebook.get_cell(0);
39 var cell = IPython.notebook.get_cell(0);
38 cell.set_text('a=12; print(a)');
40 cell.set_text('a=12; print(a)');
39 cell.clear_output()
41 cell.clear_output();
40 IPython.utils.press_shift_enter();
42 IPython.utils.press_shift_enter();
41 });
43 });
42
44
@@ -44,6 +46,8 casper.notebook_test(function () {
44
46
45 this.then(function () {
47 this.then(function () {
46 var result = this.get_output_cell(0);
48 var result = this.get_output_cell(0);
47 this.test.assertEquals(result.text, '12\n', 'cell execute (using shift-enter)')
49 var num_cells = this.get_cells_length();
50 this.test.assertEquals(result.text, '12\n', 'cell execute (using shift-enter)');
51 this.test.assertEquals(num_cells, 2, ' ^--- adds a new cell')
48 });
52 });
49 });
53 });
@@ -78,6 +78,14 casper.get_output_cell = function (cell_num) {
78 return result;
78 return result;
79 };
79 };
80
80
81 // return the number of cells in the notebook
82 casper.get_cells_length = function () {
83 var result = casper.evaluate(function () {
84 return IPython.notebook.get_cells().length;
85 })
86 return result;
87 };
88
81 // Wrap a notebook test to reduce boilerplate.
89 // Wrap a notebook test to reduce boilerplate.
82 casper.notebook_test = function(test) {
90 casper.notebook_test = function(test) {
83 this.open_new_notebook();
91 this.open_new_notebook();
General Comments 0
You need to be logged in to leave comments. Login now