diff --git a/IPython/html/tests/notebook/dualmode_markdown.js b/IPython/html/tests/notebook/dualmode_markdown.js
index d974057..e2d51c3 100644
--- a/IPython/html/tests/notebook/dualmode_markdown.js
+++ b/IPython/html/tests/notebook/dualmode_markdown.js
@@ -1,39 +1,43 @@
// Test
casper.notebook_test(function () {
+ this.is_rendered = function(i) {
+ return this.evaluate(function(i) {
+ return !!IPython.notebook.get_cell(i).rendered;
+ }, {i:i});
+ };
+
var a = 'print("a")';
var index = this.append_cell(a);
- this.execute_cell_then(index);
-
- this.then(function () {
+ this.execute_cell_then(index, function(index) {
// Markdown rendering / unredering
- this.select_cell(1);
- this.validate_notebook_state('select 1', 'command', 1);
+ this.select_cell(index);
+ this.validate_notebook_state('select ' + index, 'command', index);
this.trigger_keydown('m');
- this.test.assertEquals(this.get_cell(1).cell_type, 'markdown', 'm; cell is markdown');
- this.test.assertEquals(this.get_cell(1).rendered, false, 'm; cell is rendered');
+ this.test.assertEquals(this.get_cell(index).cell_type, 'markdown', 'm; cell is markdown');
+ this.test.assert(!this.is_rendered(index), 'm; cell is unrendered');
this.trigger_keydown('enter');
- this.test.assertEquals(this.get_cell(1).rendered, false, 'enter; cell is unrendered');
- this.validate_notebook_state('enter', 'edit', 1);
+ this.test.assert(!this.is_rendered(index), 'enter; cell is unrendered');
+ this.validate_notebook_state('enter', 'edit', index);
this.trigger_keydown('ctrl-enter');
- this.test.assertEquals(this.get_cell(1).rendered, true, 'ctrl-enter; cell is rendered');
- this.validate_notebook_state('enter', 'command', 1);
+ this.test.assert(this.is_rendered(index), 'ctrl-enter; cell is rendered');
+ this.validate_notebook_state('enter', 'command', index);
this.trigger_keydown('enter');
- this.test.assertEquals(this.get_cell(1).rendered, false, 'enter; cell is unrendered');
- this.select_cell(0);
- this.test.assertEquals(this.get_cell(1).rendered, false, 'select 0; cell 1 is still unrendered');
- this.validate_notebook_state('select 0', 'command', 0);
- this.select_cell(1);
- this.validate_notebook_state('select 1', 'command', 1);
+ this.test.assert(!this.is_rendered(index), 'enter; cell is unrendered');
+ this.select_cell(index-1);
+ this.test.assert(!this.is_rendered(index), 'select ' + (index-1) + '; cell ' + index + ' is still unrendered');
+ this.validate_notebook_state('select ' + (index-1), 'command', index-1);
+ this.select_cell(index);
+ this.validate_notebook_state('select ' + index, 'command', index);
this.trigger_keydown('ctrl-enter');
- this.test.assertEquals(this.get_cell(1).rendered, true, 'ctrl-enter; cell is rendered');
- this.select_cell(0);
- this.validate_notebook_state('select 0', 'command', 0);
+ this.test.assert(this.is_rendered(index), 'ctrl-enter; cell is rendered');
+ this.select_cell(index-1);
+ this.validate_notebook_state('select ' + (index-1), 'command', index-1);
this.trigger_keydown('shift-enter');
- this.validate_notebook_state('shift-enter', 'command', 1);
- this.test.assertEquals(this.get_cell(1).rendered, true, 'shift-enter; cell is rendered');
+ this.validate_notebook_state('shift-enter', 'command', index);
+ this.test.assert(this.is_rendered(index), 'shift-enter; cell is rendered');
this.trigger_keydown('shift-enter'); // Creates one cell
- this.validate_notebook_state('shift-enter', 'edit', 2);
- this.test.assertEquals(this.get_cell(1).rendered, true, 'shift-enter; cell is rendered');
+ this.validate_notebook_state('shift-enter', 'edit', index+1);
+ this.test.assert(this.is_rendered(index), 'shift-enter; cell is rendered');
});
});
\ No newline at end of file
diff --git a/IPython/html/tests/notebook/safe_append_output.js b/IPython/html/tests/notebook/safe_append_output.js
index 7604d7b..c8c1fa9 100644
--- a/IPython/html/tests/notebook/safe_append_output.js
+++ b/IPython/html/tests/notebook/safe_append_output.js
@@ -25,7 +25,7 @@ casper.notebook_test(function () {
this.then(function () {
var output = this.get_output_cell(0);
this.test.assert(messages.length > 0, "Captured log message");
- this.test.assertEquals(messages[messages.length-1], "Invalid type for image/png 5", "Logged Invalid type message");
+ this.test.assertEquals(messages[messages.length-1].substr(0,26), "Invalid type for image/png", "Logged Invalid type message");
this.test.assertEquals(output['image/png'], undefined, "Non-string png data was stripped");
this.test.assertEquals(output['text/plain'], '5', "text data is fine");
});