Move isImmutableConfig to a utility file
And test it.
This commit is contained in:
parent
120a2a7f54
commit
8c49d4f879
|
@ -0,0 +1,17 @@
|
|||
|
||||
var isImmutableConfig = require('plugins/kibana/settings/sections/advanced/lib/is_immutable_config');
|
||||
var expect = require('expect.js');
|
||||
|
||||
describe('Settings', function () {
|
||||
describe('Advanced', function () {
|
||||
describe('isImmutableConfig(configName)', function () {
|
||||
it('returns true given an immutable field name', function () {
|
||||
expect(isImmutableConfig('buildNum')).to.be.true;
|
||||
});
|
||||
|
||||
it('returns false given any value that does not match the whitelist', function () {
|
||||
expect(isImmutableConfig('something else')).to.be.false;
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,6 +1,8 @@
|
|||
define(function (require) {
|
||||
var _ = require('lodash');
|
||||
var toEditableConfig = require('plugins/kibana/settings/sections/advanced/lib/to_editable_config');
|
||||
var isImmutableConfig = require('plugins/kibana/settings/sections/advanced/lib/is_immutable_config');
|
||||
var notImmutableConfig = _.negate(isImmutableConfig);
|
||||
|
||||
|
||||
require('plugins/kibana/settings/sections/advanced/advanced_row');
|
||||
|
@ -20,8 +22,6 @@ define(function (require) {
|
|||
ESC: 27
|
||||
};
|
||||
|
||||
var IMMUTABLE_CONFIG_VALS = ['buildNum'];
|
||||
|
||||
function isTypeComplex(conf) {
|
||||
return !(conf.json || conf.array || conf.bool || conf.normal);
|
||||
}
|
||||
|
@ -30,10 +30,6 @@ define(function (require) {
|
|||
return !(configName in configDefaults);
|
||||
}
|
||||
|
||||
function notImmutableConfig(configName) {
|
||||
return !_.contains(IMMUTABLE_CONFIG_VALS, configName);
|
||||
}
|
||||
|
||||
function readConfigVals() {
|
||||
var configVals = config._vals();
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
define(function (require) {
|
||||
var _ = require('lodash');
|
||||
|
||||
var IMMUTABLE_CONFIG_VALS = ['buildNum'];
|
||||
|
||||
/**
|
||||
* @param {string} name of configuration
|
||||
* @returns {boolean} whether the given name matches an immutable field name
|
||||
*/
|
||||
function isImmutableConfig(configName) {
|
||||
return _.contains(IMMUTABLE_CONFIG_VALS, configName);
|
||||
}
|
||||
|
||||
return isImmutableConfig;
|
||||
});
|
Loading…
Reference in a new issue