When there is a default function and no value the tansform function should not be call.
The following test works in v5 but fails in v6 with a runtime exception since the transform function is being call with a null value Cannot read property 'map' of null
const mapper = require('object-mapper')
const format = sizes => sizes.map(data => data)
const MAPPING = {
mySizes: [
{
key: 'sizes',
transform: format,
default: () => []
}
]
}
describe('Mapping array', () => {
it('should not fail when not defined', () => {
const result = mapper({}, MAPPING)
expect(result).toEqual({sizes: []})
})
})
When there is a default function and no value the tansform function should not be call.
The following test works in v5 but fails in v6 with a runtime exception since the transform function is being call with a null value
Cannot read property 'map' of null