Skip to content

Commit

Permalink
Split up 'expandDottedObject' test (elastic#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tacklebox authored Feb 22, 2022
1 parent 2c3e6c2 commit 57a3b44
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,21 @@ const testFlattenedObj = {
emptyArray: [],
};
describe('expandDottedObject(obj)', () => {
it('works', () => {
it('retrieves values from flattened keys', () => {
const expanded: any = expandDottedObject(testFlattenedObj);

expect(expanded.flattened.property.a).toEqual('valueA');
expect(expanded.flattened.property.b).toEqual('valueB');
expect(expanded.regularProp.nestedProp).toEqual('nestedValue');
});
it('retrieves values from nested keys', () => {
const expanded: any = expandDottedObject(testFlattenedObj);

expect(Array.isArray(expanded.nested.array)).toBeTruthy();
expect(expanded.nested.array[0].arrayProp).toEqual('arrayValue');
});
it('doesn\'t break regular value access', () => {
const expanded: any = expandDottedObject(testFlattenedObj);

expect(expanded.regularProp.nestedProp).toEqual('nestedValue');
});
});

0 comments on commit 57a3b44

Please sign in to comment.