Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in Cadence Web where falsy values do not render correctly #529

Merged
merged 4 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading