diff --git a/client/helpers/get-json-string-object.js b/client/helpers/get-json-string-object.js index 5ad2d0d05..fd65add5f 100644 --- a/client/helpers/get-json-string-object.js +++ b/client/helpers/get-json-string-object.js @@ -22,8 +22,9 @@ import getStringElipsis from './get-string-elipsis'; const getJsonStringObject = value => { - const jsonStringFull = value ? JSON.stringify(value, null, 2) : ''; - const jsonStringDisplay = value ? getStringElipsis(jsonStringFull) : ''; + const jsonStringFull = + value !== undefined ? JSON.stringify(value, null, 2) : ''; + const jsonStringDisplay = getStringElipsis(jsonStringFull); return { jsonStringDisplay, diff --git a/client/helpers/get-string-elipsis.spec.js b/client/helpers/get-string-elipsis.spec.js index ce1ab0a21..13cc3a15e 100644 --- a/client/helpers/get-string-elipsis.spec.js +++ b/client/helpers/get-string-elipsis.spec.js @@ -31,6 +31,14 @@ describe('getStringElipsis', () => { expect(output).toEqual('a-short-string'); }); }); + describe('when passed the empty string', () => { + it('should return the empty string', () => { + const input = ''; + const output = getStringElipsis(input); + + expect(output).toEqual(''); + }); + }); describe('when passed a string that has a length equal to MAXIMUM_JSON_CHARACTER_LIMIT', () => { it('should return a substring of the original string up until the limit and display a message.', () => { const input = ''.padEnd(MAXIMUM_JSON_CHARACTER_LIMIT, '_');