if not in defaults use string

v1.18.x
Barış Soner Uşaklı 6 years ago
parent 4fff5e9baf
commit d07e3e6d97

@ -22,7 +22,7 @@ function deserialize(config) {
const defaultType = typeof defaults[key];
const type = typeof config[key];
if (defaultType === 'string' && type === 'number') {
if ((defaultType === 'string' || defaultType === 'undefined') && type === 'number') {
deserialized[key] = String(config[key]);
} else if (defaultType === 'number' && type === 'string') {
const number = parseFloat(config[key]);

@ -213,12 +213,12 @@ describe('meta', function () {
});
});
it('should set numeric config value', function (done) {
it('should get back string if field is not in defaults', function (done) {
meta.configs.set('numericField', 123, function (err) {
assert.ifError(err);
meta.configs.getFields(['numericField'], function (err, data) {
assert.ifError(err);
assert.strictEqual(data.numericField, 123);
assert.strictEqual(data.numericField, '123');
done();
});
});

Loading…
Cancel
Save