Skip to content

Commit

Permalink
Fix bug in Cadence Web where falsy values do not render correctly (#529)
Browse files Browse the repository at this point in the history
This change fixes an issue with cadence-web where false/0 values in the activity result do not render correctly. It makes the check for null/undefined in the getJsonStringObject function more explicit.
  • Loading branch information
adhityamamallan authored Nov 16, 2023
1 parent fcf7b34 commit f64c457
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 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,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,
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 f64c457

Please sign in to comment.