##// END OF EJS Templates
Add test for cell type modifier keyboard shortcuts
Jonathan Frederic -
Show More
@@ -63,7 +63,7 b' casper.notebook_test(function () {'
63 this.validate_state('shift+enter (no cell below)', 'edit', base_index + 1);
63 this.validate_state('shift+enter (no cell below)', 'edit', base_index + 1);
64 // not last cell in notebook & starts in edit mode
64 // not last cell in notebook & starts in edit mode
65 this.click_cell(base_index);
65 this.click_cell(base_index);
66 this.validate_state('click cell %d' % base_index, 'edit', base_index);
66 this.validate_state('click cell ' + base_index, 'edit', base_index);
67 this.trigger_keydown('shift+enter');
67 this.trigger_keydown('shift+enter');
68 this.validate_state('shift+enter (cell exists below)', 'command', base_index + 1);
68 this.validate_state('shift+enter (cell exists below)', 'command', base_index + 1);
69 // starts in command mode
69 // starts in command mode
@@ -79,7 +79,7 b' casper.notebook_test(function () {'
79 this.validate_state('ctrl+enter (no cell below)', 'command', base_index);
79 this.validate_state('ctrl+enter (no cell below)', 'command', base_index);
80 // not last cell in notebook & starts in edit mode
80 // not last cell in notebook & starts in edit mode
81 this.click_cell(base_index-1);
81 this.click_cell(base_index-1);
82 this.validate_state('click cell %d' % (base_index-1), 'edit', base_index-1);
82 this.validate_state('click cell ' + (base_index-1), 'edit', base_index-1);
83 this.trigger_keydown('ctrl+enter');
83 this.trigger_keydown('ctrl+enter');
84 this.validate_state('ctrl+enter (cell exists below)', 'command', base_index-1);
84 this.validate_state('ctrl+enter (cell exists below)', 'command', base_index-1);
85 // starts in command mode
85 // starts in command mode
@@ -90,12 +90,11 b' casper.notebook_test(function () {'
90
90
91 // alt+enter tests.
91 // alt+enter tests.
92 // last cell in notebook
92 // last cell in notebook
93 base_index++;
94 this.trigger_keydown('alt+enter'); // Creates one cell
93 this.trigger_keydown('alt+enter'); // Creates one cell
95 this.validate_state('alt+enter (no cell below)', 'edit', base_index + 1);
94 this.validate_state('alt+enter (no cell below)', 'edit', base_index + 1);
96 // not last cell in notebook & starts in edit mode
95 // not last cell in notebook & starts in edit mode
97 this.click_cell(base_index);
96 this.click_cell(base_index);
98 this.validate_state('click cell %d' % base_index, 'edit', base_index);
97 this.validate_state('click cell ' + base_index, 'edit', base_index);
99 this.trigger_keydown('alt+enter'); // Creates one cell
98 this.trigger_keydown('alt+enter'); // Creates one cell
100 this.validate_state('alt+enter (cell exists below)', 'edit', base_index + 1);
99 this.validate_state('alt+enter (cell exists below)', 'edit', base_index + 1);
101 // starts in command mode
100 // starts in command mode
@@ -106,7 +105,30 b' casper.notebook_test(function () {'
106 this.validate_state('alt+enter (start in command mode)', 'edit', base_index + 1);
105 this.validate_state('alt+enter (start in command mode)', 'edit', base_index + 1);
107
106
108 // Notebook will now have 8 cells, the index of the last cell will be 7.
107 // Notebook will now have 8 cells, the index of the last cell will be 7.
109
108 this.test.assertEquals(this.get_cells.length, 8, '*-enter commands added cells where needed.');
109 this.click_cell(7);
110 this.trigger_keydown('esc');
111 this.validate_state('click cell ' + 7 + ' and esc', 'command', 7);
112
113 this.trigger_keydown('r');
114 this.test.assertEquals(this.get_cell(7).cell_type, 'raw', 'r; cell is raw');
115 this.trigger_keydown('1');
116 this.test.assertEquals(this.get_cell(7).cell_type, 'heading', '1; cell is heading');
117 this.test.assertEquals(this.get_cell(7).level, 1, '1; cell is level 1 heading');
118 this.trigger_keydown('2');
119 this.test.assertEquals(this.get_cell(7).level, 2, '2; cell is level 2 heading');
120 this.trigger_keydown('3');
121 this.test.assertEquals(this.get_cell(7).level, 3, '3; cell is level 3 heading');
122 this.trigger_keydown('4');
123 this.test.assertEquals(this.get_cell(7).level, 4, '4; cell is level 4 heading');
124 this.trigger_keydown('5');
125 this.test.assertEquals(this.get_cell(7).level, 5, '5; cell is level 5 heading');
126 this.trigger_keydown('6');
127 this.test.assertEquals(this.get_cell(7).level, 6, '6; cell is level 6 heading');
128 this.trigger_keydown('m');
129 this.test.assertEquals(this.get_cell(7).cell_type, 'markdown', 'm; cell is markdown');
130 this.trigger_keydown('y');
131 this.test.assertEquals(this.get_cell(7).cell_type, 'code', 'y; cell is code');
110 });
132 });
111
133
112
134
General Comments 0
You need to be logged in to leave comments. Login now