mirror of
https://github.com/sasjs/adapter.git
synced 2025-12-11 09:24:35 +00:00
32 lines
673 B
TypeScript
32 lines
673 B
TypeScript
import { isValidJson } from '../../utils'
|
|
|
|
describe('jsonValidator', () => {
|
|
it('should not throw an error with an valid json', () => {
|
|
const json = {
|
|
test: 'test'
|
|
}
|
|
|
|
expect(isValidJson(json)).toBe(json)
|
|
})
|
|
|
|
it('should not throw an error with an valid json string', () => {
|
|
const json = {
|
|
test: 'test'
|
|
}
|
|
|
|
expect(isValidJson(JSON.stringify(json))).toStrictEqual(json)
|
|
})
|
|
|
|
it('should throw an error with an invalid json', () => {
|
|
const json = `{\"test\":\"test\"\"test2\":\"test\"}`
|
|
|
|
expect(() => {
|
|
try {
|
|
isValidJson(json)
|
|
} catch (err) {
|
|
throw new Error()
|
|
}
|
|
}).toThrowError
|
|
})
|
|
})
|