优化
This commit is contained in:
18
client/shared/utils/__tests__/json-helper.spec.ts
Normal file
18
client/shared/utils/__tests__/json-helper.spec.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user