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.

770 B
Raw Blame
import { apiMutator } from 'lib/api-orval-mutator'

import { useMocks } from '~/mocks/jest'

describe('apiMutator', () => {
    it('returns the parsed body of a delete that answers with one', async () => {
        useMocks({ delete: { '/api/projects/:team_id/probe/:id/': { status: 'cancelled', report_id: 7 } } })

        const result = await apiMutator('/api/projects/1/probe/2/', { method: 'DELETE' })

        expect(result).toEqual({ status: 'cancelled', report_id: 7 })
    })

    it('returns null for a delete with no content', async () => {
        useMocks({ delete: { '/api/projects/:team_id/probe/:id/': () => [204] } })

        const result = await apiMutator('/api/projects/1/probe/2/', { method: 'DELETE' })

        expect(result).toBeNull()
    })
})