Files
30-seconds-of-code/node_modules/graphql-compose/mjs/utils/__tests__/toDottedObject-test.mjs
2019-08-20 15:52:05 +02:00

28 lines
490 B
JavaScript

import toDottedObject from '../toDottedObject';
describe('toDottedObject()', () => {
it('should dot nested objects', () => {
expect(toDottedObject({
a: {
b: {
c: 1
}
}
})).toEqual({
'a.b.c': 1
});
});
it('should work with arrays', () => {
expect(toDottedObject({
a: {
b: [{
c: 1
}, {
d: 1
}]
}
})).toEqual({
'a.b.0.c': 1,
'a.b.1.d': 1
});
});
});