diff --git a/__tests__/index.test.jsx b/__tests__/index.test.jsx index 4403d11..8b67efa 100644 --- a/__tests__/index.test.jsx +++ b/__tests__/index.test.jsx @@ -47,6 +47,12 @@ describe('single variable', () => { }); it.todo('should set `selected` if nothing is selected'); + + it('should render objects as strings', () => { + const variable = shallow(); + + expect(variable.text()).toBe(JSON.stringify({ renderTo: 'string' })); + }); }); describe('multiple variables', () => { diff --git a/index.jsx b/index.jsx index 617578a..84cfa19 100644 --- a/index.jsx +++ b/index.jsx @@ -33,9 +33,9 @@ class Variable extends React.Component { // - uppercase key getValue() { const { variable } = this.props; - if (this.props.user[variable]) return this.props.user[variable]; + const value = this.props.user[variable] || this.getDefault(); - return this.getDefault(); + return typeof value === 'object' ? JSON.stringify(value) : value; } toggleVarDropdown() {