diff --git a/__tests__/src/getPropValue-test.js b/__tests__/src/getPropValue-test.js index adb9c0e..2f5e75b 100644 --- a/__tests__/src/getPropValue-test.js +++ b/__tests__/src/getPropValue-test.js @@ -777,6 +777,15 @@ describe('getPropValue', () => { assert.deepEqual(expected, actual); }); + + it('should evaluate to a correct representation of the object, ignore spread properties', () => { + const prop = extractProp('
'); + + const expected = { pathname: 'manageRoute', state: {} }; + const actual = getPropValue(prop); + + assert.deepEqual(expected, actual); + }); }); describe('New expression', () => { diff --git a/src/values/expressions/ObjectExpression.js b/src/values/expressions/ObjectExpression.js index b8a446f..55f34bc 100644 --- a/src/values/expressions/ObjectExpression.js +++ b/src/values/expressions/ObjectExpression.js @@ -9,7 +9,8 @@ import getValue from './index'; export default function extractValueFromObjectExpression(value) { return value.properties.reduce((obj, property) => { const object = Object.assign({}, obj); - if (property.type === 'SpreadProperty') { + // Support types: SpreadProperty and ExperimentalSpreadProperty + if (/SpreadProperty/.test(property.type)) { if (property.argument.type === 'ObjectExpression') { return Object.assign(object, extractValueFromObjectExpression(property.argument)); }