##// END OF EJS Templates
add (failling) roundtrip test case
Paul Ivanov -
Show More
@@ -1,48 +1,63
1 1 // Test opening a rich notebook, saving it, and reopening it again.
2 2 //
3 3 //toJSON fromJSON toJSON and do a string comparison
4 4 casper.notebook_test(function () {
5 5 this.evaluate(function () {
6 6 var cell = IPython.notebook.get_cell(0);
7 7 // "we have to make messes to find out who we are"
8 8 cell.set_text([
9 9 "%%javascript",
10 "IPython.notebook.insert_cell_above('code')"
10 "IPython.notebook.insert_cell_below('code')"
11 11 ].join('\n')
12 12 );
13 13
14 14 cell.execute();
15 15 });
16 16
17 17 this.wait_for_output(0);
18 18
19 19 this.then(function ( ) {
20 var result = this.get_output_cell(1);
20 var result = this.get_output_cell(0);
21 21 var num_cells = this.get_cells_length();
22 22 this.test.assertEquals(num_cells, 2, '%%javascript magic works');
23 this.test.assertTrue(result.hasOwnProperty('application/javascript'), 'JS embeded with mime key');
23 this.test.assertTrue(result.hasOwnProperty('application/javascript'),
24 'JS embeded with mime key');
24 25 });
25 26
27 //this.thenEvaluate(function() { IPython.notebook.save_notebook(); });
26 28
27 //this.thenEvaluate(function () { var cell = IPython.notebook.get_cell(0);
29 this.then(function ( ) {
30 json = this.evaluate(function() {
31 // the appended cell will initiall be empty
32 var json = IPython.notebook.get_cell(0).output_area.toJSON();
33 var cell = IPython.notebook.get_cell(1).output_area.fromJSON(json);
34 return json;
35 });
36 var result = this.get_output_cell(0);
37 var result2 = this.get_output_cell(1);
38 this.test.assertTrue(result.hasOwnProperty('application/javascript'),
39 'embeded JS keeps mime key after save');
40 this.test.assertTrue(json[0].hasOwnProperty('javascript'),
41 'JSON representation uses short keys');
42 this.test.assertTrue(result2.hasOwnProperty('application/javascript'),
43 'embeded JS keeps mime key on fromJSON');
44
45 });
46
47
48 //this.thenEvaluate(function () {
49 //var cell = IPython.notebook.get_cell(0);
28 50
29 51 // // we have to make messes to find out who we are
30 52 // cell.set_text([
31 53 // "import IPython.html.tests as t",
32 54 // "t.write_test_notebook('rich_output.ipynb')"
33 55 // ].join('\n')
34 56 // );
35 57
36 58 // cell.execute();
37 59 //});
38 60 //
39 61 //this.wait_for_output(0);
40 62
41 //this.then(function ( ) {
42 // var result = this.get_output_cell(0);
43 // var num_cells = this.get_cells_length();
44 // this.test.assertEquals(result.text, '10\n', 'opening notebook JSON');
45 // this.test.assertEquals(num_cells, 2, ' %%javascript magic works')
46 //});
47
48 63 });
General Comments 0
You need to be logged in to leave comments. Login now