You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tailchat/client/shared/utils/__tests__/json-helper.spec.ts

19 lines
418 B
TypeScript

import { isValidJson } from '../json-helper';
describe('isValidJson', () => {
test.each([
['foo', false],
['[]', true],
['{}', true],
['{"foo": []}', true],
['{"foo": [}', false],
['{foo: bar}', false],
['{"foo": "bar"}', true],
[[], false],
[null, false],
[undefined, false],
])('%s => %s', (input: any, should) => {
expect(isValidJson(input)).toBe(should);
});
});