##// END OF EJS Templates
Make notebook tests play nicely with SlimerJS...
Jonathan Frederic -
Show More
@@ -1,39 +1,43 b''
1 1
2 2 // Test
3 3 casper.notebook_test(function () {
4 this.is_rendered = function(i) {
5 return this.evaluate(function(i) {
6 return !!IPython.notebook.get_cell(i).rendered;
7 }, {i:i});
8 };
9
4 10 var a = 'print("a")';
5 11 var index = this.append_cell(a);
6 this.execute_cell_then(index);
7
8 this.then(function () {
12 this.execute_cell_then(index, function(index) {
9 13 // Markdown rendering / unredering
10 this.select_cell(1);
11 this.validate_notebook_state('select 1', 'command', 1);
14 this.select_cell(index);
15 this.validate_notebook_state('select ' + index, 'command', index);
12 16 this.trigger_keydown('m');
13 this.test.assertEquals(this.get_cell(1).cell_type, 'markdown', 'm; cell is markdown');
14 this.test.assertEquals(this.get_cell(1).rendered, false, 'm; cell is rendered');
17 this.test.assertEquals(this.get_cell(index).cell_type, 'markdown', 'm; cell is markdown');
18 this.test.assert(!this.is_rendered(index), 'm; cell is unrendered');
15 19 this.trigger_keydown('enter');
16 this.test.assertEquals(this.get_cell(1).rendered, false, 'enter; cell is unrendered');
17 this.validate_notebook_state('enter', 'edit', 1);
20 this.test.assert(!this.is_rendered(index), 'enter; cell is unrendered');
21 this.validate_notebook_state('enter', 'edit', index);
18 22 this.trigger_keydown('ctrl-enter');
19 this.test.assertEquals(this.get_cell(1).rendered, true, 'ctrl-enter; cell is rendered');
20 this.validate_notebook_state('enter', 'command', 1);
23 this.test.assert(this.is_rendered(index), 'ctrl-enter; cell is rendered');
24 this.validate_notebook_state('enter', 'command', index);
21 25 this.trigger_keydown('enter');
22 this.test.assertEquals(this.get_cell(1).rendered, false, 'enter; cell is unrendered');
23 this.select_cell(0);
24 this.test.assertEquals(this.get_cell(1).rendered, false, 'select 0; cell 1 is still unrendered');
25 this.validate_notebook_state('select 0', 'command', 0);
26 this.select_cell(1);
27 this.validate_notebook_state('select 1', 'command', 1);
26 this.test.assert(!this.is_rendered(index), 'enter; cell is unrendered');
27 this.select_cell(index-1);
28 this.test.assert(!this.is_rendered(index), 'select ' + (index-1) + '; cell ' + index + ' is still unrendered');
29 this.validate_notebook_state('select ' + (index-1), 'command', index-1);
30 this.select_cell(index);
31 this.validate_notebook_state('select ' + index, 'command', index);
28 32 this.trigger_keydown('ctrl-enter');
29 this.test.assertEquals(this.get_cell(1).rendered, true, 'ctrl-enter; cell is rendered');
30 this.select_cell(0);
31 this.validate_notebook_state('select 0', 'command', 0);
33 this.test.assert(this.is_rendered(index), 'ctrl-enter; cell is rendered');
34 this.select_cell(index-1);
35 this.validate_notebook_state('select ' + (index-1), 'command', index-1);
32 36 this.trigger_keydown('shift-enter');
33 this.validate_notebook_state('shift-enter', 'command', 1);
34 this.test.assertEquals(this.get_cell(1).rendered, true, 'shift-enter; cell is rendered');
37 this.validate_notebook_state('shift-enter', 'command', index);
38 this.test.assert(this.is_rendered(index), 'shift-enter; cell is rendered');
35 39 this.trigger_keydown('shift-enter'); // Creates one cell
36 this.validate_notebook_state('shift-enter', 'edit', 2);
37 this.test.assertEquals(this.get_cell(1).rendered, true, 'shift-enter; cell is rendered');
40 this.validate_notebook_state('shift-enter', 'edit', index+1);
41 this.test.assert(this.is_rendered(index), 'shift-enter; cell is rendered');
38 42 });
39 43 }); No newline at end of file
@@ -25,7 +25,7 b' casper.notebook_test(function () {'
25 25 this.then(function () {
26 26 var output = this.get_output_cell(0);
27 27 this.test.assert(messages.length > 0, "Captured log message");
28 this.test.assertEquals(messages[messages.length-1], "Invalid type for image/png 5", "Logged Invalid type message");
28 this.test.assertEquals(messages[messages.length-1].substr(0,26), "Invalid type for image/png", "Logged Invalid type message");
29 29 this.test.assertEquals(output['image/png'], undefined, "Non-string png data was stripped");
30 30 this.test.assertEquals(output['text/plain'], '5', "text data is fine");
31 31 });
General Comments 0
You need to be logged in to leave comments. Login now