##// END OF EJS Templates
Move validate notebook state into utils
Jonathan Frederic -
Show More
@@ -282,44 +282,4 b' casper.notebook_test(function () {'
282 this.validate_notebook_state('merge', 'command', 0);
282 this.validate_notebook_state('merge', 'command', 0);
283 this.test.assertEquals(this.get_cell_text(0), 'ab\ncd', 'merge; Verify that cell 0 has the merged contents.');
283 this.test.assertEquals(this.get_cell_text(0), 'ab\ncd', 'merge; Verify that cell 0 has the merged contents.');
284 });
284 });
285
286 // Utility functions.
287 this.validate_notebook_state = function(message, mode, cell_index) {
288 // General tests.
289 this.test.assertEquals(this.get_keyboard_mode(), this.get_notebook_mode(),
290 message + '; keyboard and notebook modes match');
291 // Is the selected cell the only cell that is selected?
292 if (cell_index!==undefined) {
293 this.test.assert(this.is_only_cell_selected(cell_index),
294 message + '; cell ' + cell_index + ' is the only cell selected');
295 }
296
297 // Mode specific tests.
298 if (mode==='command') {
299 // Are the notebook and keyboard manager in command mode?
300 this.test.assertEquals(this.get_keyboard_mode(), 'command',
301 message + '; in command mode');
302 // Make sure there isn't a single cell in edit mode.
303 this.test.assert(this.is_only_cell_edit(null),
304 message + '; all cells in command mode');
305 this.test.assert(this.is_cell_editor_focused(null),
306 message + '; no cell editors are focused while in command mode');
307
308 } else if (mode==='edit') {
309 // Are the notebook and keyboard manager in edit mode?
310 this.test.assertEquals(this.get_keyboard_mode(), 'edit',
311 message + '; in edit mode');
312 if (cell_index!==undefined) {
313 // Is the specified cell the only cell in edit mode?
314 this.test.assert(this.is_only_cell_edit(cell_index),
315 message + '; cell ' + cell_index + ' is the only cell in edit mode');
316 // Is the specified cell the only cell with a focused code mirror?
317 this.test.assert(this.is_cell_editor_focused(cell_index),
318 message + '; cell ' + cell_index + '\'s editor is appropriately focused');
319 }
320
321 } else {
322 this.test.assert(false, message + '; ' + mode + ' is an unknown mode');
323 }
324 };
325 });
285 });
@@ -233,6 +233,44 b' casper.cell_element_function = function(index, selector, function_name, function'
233 }, index, selector, function_name, function_args);
233 }, index, selector, function_name, function_args);
234 };
234 };
235
235
236 casper.validate_notebook_state = function(message, mode, cell_index) {
237 // General tests.
238 this.test.assertEquals(this.get_keyboard_mode(), this.get_notebook_mode(),
239 message + '; keyboard and notebook modes match');
240 // Is the selected cell the only cell that is selected?
241 if (cell_index!==undefined) {
242 this.test.assert(this.is_only_cell_selected(cell_index),
243 message + '; cell ' + cell_index + ' is the only cell selected');
244 }
245
246 // Mode specific tests.
247 if (mode==='command') {
248 // Are the notebook and keyboard manager in command mode?
249 this.test.assertEquals(this.get_keyboard_mode(), 'command',
250 message + '; in command mode');
251 // Make sure there isn't a single cell in edit mode.
252 this.test.assert(this.is_only_cell_edit(null),
253 message + '; all cells in command mode');
254 this.test.assert(this.is_cell_editor_focused(null),
255 message + '; no cell editors are focused while in command mode');
256
257 } else if (mode==='edit') {
258 // Are the notebook and keyboard manager in edit mode?
259 this.test.assertEquals(this.get_keyboard_mode(), 'edit',
260 message + '; in edit mode');
261 if (cell_index!==undefined) {
262 // Is the specified cell the only cell in edit mode?
263 this.test.assert(this.is_only_cell_edit(cell_index),
264 message + '; cell ' + cell_index + ' is the only cell in edit mode');
265 // Is the specified cell the only cell with a focused code mirror?
266 this.test.assert(this.is_cell_editor_focused(cell_index),
267 message + '; cell ' + cell_index + '\'s editor is appropriately focused');
268 }
269
270 } else {
271 this.test.assert(false, message + '; ' + mode + ' is an unknown mode');
272 }
273 };
236
274
237 casper.select_cell = function(index) {
275 casper.select_cell = function(index) {
238 this.evaluate(function (i) {
276 this.evaluate(function (i) {
General Comments 0
You need to be logged in to leave comments. Login now