fix: Parse Server databaseOptions nested keys incorrectly identified as invalid (#9213)
This commit is contained in:
49
spec/Utils.spec.js
Normal file
49
spec/Utils.spec.js
Normal file
@@ -0,0 +1,49 @@
|
||||
const Utils = require('../src/Utils');
|
||||
|
||||
describe('Utils', () => {
|
||||
describe('addNestedKeysToRoot', () => {
|
||||
it('should move the nested keys to root of object', async () => {
|
||||
const obj = {
|
||||
a: 1,
|
||||
b: {
|
||||
c: 2,
|
||||
d: 3
|
||||
},
|
||||
e: 4
|
||||
};
|
||||
Utils.addNestedKeysToRoot(obj, 'b');
|
||||
expect(obj).toEqual({
|
||||
a: 1,
|
||||
c: 2,
|
||||
d: 3,
|
||||
e: 4
|
||||
});
|
||||
});
|
||||
|
||||
it('should not modify the object if the key does not exist', async () => {
|
||||
const obj = {
|
||||
a: 1,
|
||||
e: 4
|
||||
};
|
||||
Utils.addNestedKeysToRoot(obj, 'b');
|
||||
expect(obj).toEqual({
|
||||
a: 1,
|
||||
e: 4
|
||||
});
|
||||
});
|
||||
|
||||
it('should not modify the object if the key is not an object', () => {
|
||||
const obj = {
|
||||
a: 1,
|
||||
b: 2,
|
||||
e: 4
|
||||
};
|
||||
Utils.addNestedKeysToRoot(obj, 'b');
|
||||
expect(obj).toEqual({
|
||||
a: 1,
|
||||
b: 2,
|
||||
e: 4
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user