Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

637 B
Raw Blame
import { parseJsonObject } from './utils'

describe('dataset JSON utils', () => {
    it.each([
        ['an array', '[1, 2]'],
        ['a number', '5'],
        ['null', 'null'],
    ])('rejects %s where a JSON object is required', (_name, value) => {
        expect(() => parseJsonObject(value)).toThrow(TypeError)
    })

    it.each([
        ['a populated object', '{"key": "value"}', { key: 'value' }],
        ['an empty object', '{}', {}],
        ['an empty string', '', {}],
        ['null input', null, {}],
    ])('parses %s', (_name, value, expected) => {
        expect(parseJsonObject(value)).toEqual(expected)
    })
})