Skip to content

Commit

Permalink
Don't throw error when value is empty in value editor
Browse files Browse the repository at this point in the history
- AUT-2588
  • Loading branch information
lloki-emarsys committed Jan 30, 2024
1 parent 7030348 commit 65659f6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ describe('ValueEditor', () => {
const { vm } = mountWithStore(ValueEditor, { propsData: { value: 'something' } });
expect(vm.editorLanguage).to.eql('text');
});

it('should return text when value is null', () => {
const { vm } = mountWithStore(ValueEditor, { propsData: { value: null } });
expect(vm.editorLanguage).to.eql('text');
});
});

describe('#editorTheme', () => {
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/lib/json-helper/json-helper.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { neatJSON } from 'neatjson';
import { isEmpty } from 'lodash';

export const isValidJson = (data) => {
if (!looksLikeJson(data)) return false;
Expand All @@ -15,6 +16,9 @@ export const isJsonWithErrors = (value) => {
};

export const looksLikeJson = (value) => {
if (isEmpty(value)) {
return false;
}
const valueWithoutSpaces = value.toString().replace(/\s/g, '');
return (
(valueWithoutSpaces.startsWith('{') && valueWithoutSpaces.endsWith('}')) ||
Expand Down

0 comments on commit 65659f6

Please sign in to comment.