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.

946 B
Raw Blame
import '@testing-library/jest-dom'

import { cleanup, fireEvent, render, screen } from '@testing-library/react'

import { OnboardingProductConfigurationOption } from './OnboardingProductConfigurationOption'

describe('OnboardingProductConfigurationOption', () => {
    afterEach(() => {
        cleanup()
    })

    it.each([
        { value: false, expected: true },
        { value: true, expected: false },
    ])('clicking the toggle title flips it from $value to $expected', ({ value, expected }) => {
        const onChange = jest.fn()
        render(
            <OnboardingProductConfigurationOption
                teamProperty="heatmaps_opt_in"
                title="Enable heatmaps"
                type="toggle"
                value={value}
                onChange={onChange}
            />
        )

        fireEvent.click(screen.getByText('Enable heatmaps'))

        expect(onChange).toHaveBeenCalledWith(expected)
    })
})