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.

796 B
Raw Blame
import { HogFunctionType } from '~/types'

import { urlForHogFunction } from './HogFunctionsList'

const makeFn = (id: string): HogFunctionType => ({ id }) as HogFunctionType

describe('urlForHogFunction', () => {
    it('returns the bare hog function path when returnTo is undefined', () => {
        expect(urlForHogFunction(makeFn('abc123'))).toBe('/functions/abc123')
    })

    it('appends returnTo as a query param for a hog function id', () => {
        expect(urlForHogFunction(makeFn('abc123'), '/health/sdk-health')).toBe(
            '/functions/abc123?returnTo=%2Fhealth%2Fsdk-health'
        )
    })

    it('does not append returnTo for plugin- prefix IDs', () => {
        expect(urlForHogFunction(makeFn('plugin-7'), '/health/sdk-health')).toBe('/pipeline/plugins/7')
    })
})