From 3a7bc354863117bb5ac6746d42acbd4a56d4a8e0 2014-12-14 23:21:38 From: Thomas Kluyver Date: 2014-12-14 23:21:38 Subject: [PATCH] Update test to modify class config for default_cell_type --- diff --git a/IPython/html/static/services/config.js b/IPython/html/static/services/config.js index 0d9d559..0d2a9f9 100644 --- a/IPython/html/static/services/config.js +++ b/IPython/html/static/services/config.js @@ -48,7 +48,14 @@ function($, utils) { }); }; + /** + * Modify the config values stored. Update the local data immediately, + * send the change to the server, and use the updated data from the server + * when the reply comes. + */ ConfigSection.prototype.update = function(newdata) { + $.extend(true, this.data, newdata); // true -> recursive update + var that = this; return utils.promising_ajax(this.api_url(), { processData: false, @@ -97,6 +104,24 @@ function($, utils) { return this._class_data()[key] || this.defaults[key]; }; + /** + * Set a config value. Send the update to the server, and change our + * local copy of the data immediately. + * Returns a promise which is fulfilled when the server replies to the + * change. + */ + ConfigWithDefaults.prototype.set = function(key, value) { + var d = {}; + d[key] = value; + if (this.classname) { + var d2 = {}; + d2[this.classname] = d; + return this.section.update(d2); + } else { + return this.section.update(d); + } + }; + return {ConfigSection: ConfigSection, ConfigWithDefaults: ConfigWithDefaults, }; diff --git a/IPython/html/tests/notebook/dualmode_cellinsert.js b/IPython/html/tests/notebook/dualmode_cellinsert.js index 1764042..093f5b6 100644 --- a/IPython/html/tests/notebook/dualmode_cellinsert.js +++ b/IPython/html/tests/notebook/dualmode_cellinsert.js @@ -33,7 +33,7 @@ casper.notebook_test(function () { }); this.thenEvaluate(function() { - IPython.notebook.default_cell_type = 'selected'; + IPython.notebook.class_config.set('default_cell_type', 'selected'); }); this.then(function () { @@ -47,7 +47,7 @@ casper.notebook_test(function () { }); this.thenEvaluate(function() { - IPython.notebook.default_cell_type = 'above'; + IPython.notebook.class_config.set('default_cell_type', 'above'); }); this.then(function () { @@ -61,7 +61,7 @@ casper.notebook_test(function () { }); this.thenEvaluate(function() { - IPython.notebook.default_cell_type = 'below'; + IPython.notebook.class_config.set('default_cell_type', 'below'); }); this.then(function () {