PluginProbe
Extendify / 3.0.4
Extendify v3.0.4
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / src / Shared / lib / __tests__ / parsing.test.js

parsing.test.js in Extendify 3.0.4, at src/Shared/lib/__tests__/parsing.test.js

31 lines 816 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { safeParseJson } from '@shared/lib/parsing';
2
3 describe('safeParseJson', () => {
4 it('parses valid JSON string', () => {
5 const json = '{"name": "Test", "active": true}';
6 const result = safeParseJson(json);
7 expect(result).toEqual({ name: 'Test', active: true });
8 });
9
10 it('returns empty object for invalid JSON', () => {
11 const json = '{name: Test,}';
12 const result = safeParseJson(json);
13 expect(result).toEqual({});
14 });
15
16 it('returns empty object for empty string', () => {
17 const result = safeParseJson('');
18 expect(result).toEqual({});
19 });
20
21 it('returns empty object for null', () => {
22 const result = safeParseJson(null);
23 expect(result).toEqual({});
24 });
25
26 it('returns empty object for undefined', () => {
27 const result = safeParseJson(undefined);
28 expect(result).toEqual({});
29 });
30 });
31