Merge pull request #4608 from LuisARodr/dualmode_tests
Convert dualmode_cellmode to selenium
commit
93099010ff
@ -1,51 +0,0 @@
|
||||
// Test keyboard shortcuts that change the cell's mode.
|
||||
|
||||
// Test
|
||||
casper.notebook_test(function () {
|
||||
function get_cell_cm_mode(index) {
|
||||
return casper.evaluate(function (index) {
|
||||
return Jupyter.notebook.get_cell(index).code_mirror.getMode().name;
|
||||
}, {index: index});
|
||||
}
|
||||
|
||||
this.then(function () {
|
||||
// Cell mode change
|
||||
var that = this;
|
||||
var index = 0;
|
||||
this.select_cell(index);
|
||||
var a = 'hello\nmulti\nline';
|
||||
this.set_cell_text(index, a);
|
||||
this.trigger_keydown('esc','r');
|
||||
this.test.assertEquals(this.get_cell(index).cell_type, 'raw', 'r; cell is raw');
|
||||
this.test.assertEquals(get_cell_cm_mode(index), 'null', 'raw cell codemirror mode is null');
|
||||
this.trigger_keydown('1');
|
||||
this.test.assertEquals(this.get_cell(index).cell_type, 'markdown', '1; cell is markdown');
|
||||
this.test.assertEquals(this.get_cell_text(index), '# ' + a, '1; markdown heading');
|
||||
this.test.assertEquals(get_cell_cm_mode(index), 'ipythongfm', 'codemirror cell mode is ipythongfm');
|
||||
this.trigger_keydown('2');
|
||||
this.test.assertEquals(this.get_cell(index).cell_type, 'markdown', '2; cell is markdown');
|
||||
this.test.assertEquals(this.get_cell_text(index), '## ' + a, '2; markdown heading');
|
||||
this.trigger_keydown('3');
|
||||
this.test.assertEquals(this.get_cell(index).cell_type, 'markdown', '3; cell is markdown');
|
||||
this.test.assertEquals(this.get_cell_text(index), '### ' + a, '3; markdown heading');
|
||||
this.trigger_keydown('4');
|
||||
this.test.assertEquals(this.get_cell(index).cell_type, 'markdown', '4; cell is markdown');
|
||||
this.test.assertEquals(this.get_cell_text(index), '#### ' + a, '4; markdown heading');
|
||||
this.trigger_keydown('5');
|
||||
this.test.assertEquals(this.get_cell(index).cell_type, 'markdown', '5; cell is markdown');
|
||||
this.test.assertEquals(this.get_cell_text(index), '##### ' + a, '5; markdown heading');
|
||||
this.trigger_keydown('6');
|
||||
this.test.assertEquals(this.get_cell(index).cell_type, 'markdown', '6; cell is markdown');
|
||||
this.test.assertEquals(this.get_cell_text(index), '###### ' + a, '6; markdown heading');
|
||||
this.trigger_keydown('m');
|
||||
this.test.assertEquals(this.get_cell(index).cell_type, 'markdown', 'm; cell is markdown');
|
||||
this.test.assertEquals(this.get_cell_text(index), '###### ' + a, 'm; still markdown heading');
|
||||
this.trigger_keydown('y');
|
||||
this.test.assertEquals(this.get_cell(index).cell_type, 'code', 'y; cell is code');
|
||||
this.test.assertEquals(this.get_cell_text(index), '###### ' + a, 'y; still has hashes');
|
||||
this.test.assertEquals(get_cell_cm_mode(index), 'ipython', 'code cell mode is ipython');
|
||||
this.trigger_keydown('1');
|
||||
this.test.assertEquals(this.get_cell(index).cell_type, 'markdown', '1; cell is markdown');
|
||||
this.test.assertEquals(this.get_cell_text(index), '# ' + a, '1; markdown heading');
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,58 @@
|
||||
"""Test keyboard shortcuts that change the cell's mode."""
|
||||
|
||||
def test_dualmode_cellmode(notebook):
|
||||
def get_cell_cm_mode(index):
|
||||
code_mirror_mode = notebook.browser.execute_script(
|
||||
"return Jupyter.notebook.get_cell(%s).code_mirror.getMode().name;"%index)
|
||||
return code_mirror_mode
|
||||
|
||||
|
||||
index = 0
|
||||
a = 'hello\nmulti\nline'
|
||||
|
||||
notebook.edit_cell(index=index, content=a)
|
||||
|
||||
"""check for the default cell type"""
|
||||
notebook.to_command_mode()
|
||||
notebook.body.send_keys("r")
|
||||
assert notebook.get_cell_type(index) == 'raw'
|
||||
assert get_cell_cm_mode(index) == 'null'
|
||||
|
||||
"""check cell type after changing to markdown"""
|
||||
notebook.body.send_keys("1")
|
||||
assert notebook.get_cell_type(index) == 'markdown'
|
||||
assert notebook.get_cell_contents(index) == '# ' + a
|
||||
assert get_cell_cm_mode(index) == 'ipythongfm'
|
||||
|
||||
notebook.body.send_keys("2")
|
||||
assert notebook.get_cell_type(index) == 'markdown'
|
||||
assert notebook.get_cell_contents(index) == '## ' + a
|
||||
|
||||
notebook.body.send_keys("3")
|
||||
assert notebook.get_cell_type(index) == 'markdown'
|
||||
assert notebook.get_cell_contents(index) == '### ' + a
|
||||
|
||||
notebook.body.send_keys("4")
|
||||
assert notebook.get_cell_type(index) == 'markdown'
|
||||
assert notebook.get_cell_contents(index) == '#### ' + a
|
||||
|
||||
notebook.body.send_keys("5")
|
||||
assert notebook.get_cell_type(index) == 'markdown'
|
||||
assert notebook.get_cell_contents(index) == '##### ' + a
|
||||
|
||||
notebook.body.send_keys("6")
|
||||
assert notebook.get_cell_type(index) == 'markdown'
|
||||
assert notebook.get_cell_contents(index) == '###### ' + a
|
||||
|
||||
notebook.body.send_keys("m")
|
||||
assert notebook.get_cell_type(index) == 'markdown'
|
||||
assert notebook.get_cell_contents(index) == '###### ' + a
|
||||
|
||||
notebook.body.send_keys("y")
|
||||
assert notebook.get_cell_type(index) == 'code'
|
||||
assert notebook.get_cell_contents(index) == '###### ' + a
|
||||
assert get_cell_cm_mode(index) == 'ipython'
|
||||
|
||||
notebook.body.send_keys("1")
|
||||
assert notebook.get_cell_type(index) == 'markdown'
|
||||
assert notebook.get_cell_contents(index) == '# ' + a
|
||||
Loading…
Reference in new issue