##// END OF EJS Templates
plain text and json display_data and pyout tests
Paul Ivanov -
Show More
@@ -13,7 +13,7 b' casper.notebook_test(function () {'
13
13
14 cell.execute();
14 cell.execute();
15 });
15 });
16
16
17 this.wait_for_output(0);
17 this.wait_for_output(0);
18
18
19 this.then(function ( ) {
19 this.then(function ( ) {
@@ -44,8 +44,68 b' casper.notebook_test(function () {'
44
44
45 });
45 });
46
46
47 this.then(function() {
48 // test output of text/plain and application/json keys
49 this.evaluate(function() {
50 IPython.notebook.get_cell(0).clear_output();
51 IPython.notebook.get_cell(1).clear_output();
52 });
53 this.set_cell_text(0, "%lsmagic");
54 this.execute_cell(0);
55 });
56
57 this.then(function ( ) {
58 json = this.evaluate(function() {
59 var json = IPython.notebook.get_cell(0).output_area.toJSON();
60 // appended cell will initially be empty, lets add it some output
61 var cell = IPython.notebook.get_cell(1).output_area.fromJSON(json);
62 return json;
63 });
64 var result = this.get_output_cell(0);
65 var result2 = this.get_output_cell(1);
66 this.test.assertEquals(result.output_type, 'pyout',
67 'testing pyout application/json and text/plain');
68 this.test.assertTrue(result.hasOwnProperty('application/json'),
69 'toJSON() original embeded JSON keeps mime key');
70 this.test.assertTrue(json[0].hasOwnProperty('json'),
71 'toJSON() representation uses short key');
72 this.test.assertTrue(result2.hasOwnProperty('application/json'),
73 'fromJSON() embeded JS gets mime key');
74
75 });
76 this.then(function() {
77 // test display of text/plain and application/json keys
78 this.evaluate(function() {
79 IPython.notebook.get_cell(0).clear_output();
80 IPython.notebook.get_cell(1).clear_output();
81 });
82 this.set_cell_text(0,
83 "x = %lsmagic\nfrom IPython.display import display; display(x)");
84 this.execute_cell(0);
85 });
86
87 this.then(function ( ) {
88 json = this.evaluate(function() {
89 var json = IPython.notebook.get_cell(0).output_area.toJSON();
90 // appended cell will initially be empty, lets add it some output
91 var cell = IPython.notebook.get_cell(1).output_area.fromJSON(json);
92 return json;
93 });
94 var result = this.get_output_cell(0);
95 var result2 = this.get_output_cell(1);
96 this.test.assertEquals(result.output_type, 'display_data',
97 'testing display_data application/json and text/plain');
98 this.test.assertTrue(result.hasOwnProperty('text/plain'),
99 'toJSON()\t original embeded text keeps mime key');
100 this.test.assertTrue(json[0].hasOwnProperty('text'),
101 'toJSON()\t representation uses short key');
102 this.test.assertTrue(result2.hasOwnProperty('text/plain'),
103 'fromJSON()\t embeded text gets mime key');
104
105 });
106
47
107
48 //this.thenEvaluate(function () {
108 //this.thenEvaluate(function () {
49 //var cell = IPython.notebook.get_cell(0);
109 //var cell = IPython.notebook.get_cell(0);
50
110
51 // // we have to make messes to find out who we are
111 // // we have to make messes to find out who we are
General Comments 0
You need to be logged in to leave comments. Login now