import { stringContainsJson } from './utils'

describe('utils:stringContainsJson', () => {
    it('should return true for JSON strings', async () => {
        expect(stringContainsJson('{"foo":"bar"}')).toBe(true)
    })

    it('should return false for falsy values, invalid JSON, urls, and other non JSON strings', async () => {
        expect(stringContainsJson('')).toBe(false)
        expect(stringContainsJson(null)).toBe(false)
        expect(stringContainsJson(undefined)).toBe(false)
        expect(stringContainsJson('{"foo":"bar", "whoops"}')).toBe(false)
        expect(stringContainsJson('http://www.google.com')).toBe(false)
        expect(stringContainsJson('foo')).toBe(false)
    })
})
