msw
Version:
14 lines (11 loc) • 378 B
text/typescript
import { jsonParse } from './jsonParse'
test('parses a given valid JSON string', () => {
expect(jsonParse(`{"property":"value"}`)).toEqual({
property: 'value',
})
})
test('returns undefined without an error given an invalid JSON string', () => {
const parse = () => jsonParse(`{"property:val"ue$}`)
expect(parse).not.toThrow()
expect(parse()).toBeUndefined()
})