Skip to content

Commit

Permalink
Fix bug in Cadence Web where falsy values do not render correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
adhityamamallan committed Nov 15, 2023
1 parent fcf7b34 commit 62495a6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions client/helpers/get-json-string-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
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 !== null && value !== undefined ? JSON.stringify(value, null, 2) : '';

Check failure on line 25 in client/helpers/get-json-string-object.js

View workflow job for this annotation

GitHub Actions / build

Insert `⏎···`

Check failure on line 25 in client/helpers/get-json-string-object.js

View workflow job for this annotation

GitHub Actions / build

Insert `⏎···`
const jsonStringDisplay = getStringElipsis(jsonStringFull);

return {
jsonStringDisplay,
Expand Down
8 changes: 8 additions & 0 deletions client/helpers/get-string-elipsis.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, '_');
Expand Down

0 comments on commit 62495a6

Please sign in to comment.