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.

967 B
Raw Blame
import { estimateCheckSlotsNext24h } from './scheduleRestrictionPreview'

describe('scheduleRestrictionPreview', () => {
    const overnight = [{ start: '22:00', end: '07:00' }]

    it('returns full slot count when no quiet hours are configured', () => {
        expect(estimateCheckSlotsNext24h(null, 'UTC', 60)).toBe(24)
        expect(estimateCheckSlotsNext24h(undefined, 'UTC', 15)).toBe(96)
        expect(estimateCheckSlotsNext24h(undefined, 'UTC', 5)).toBe(288)
    })

    it('counts fewer hourly slots when overnight quiet hours block most of the day', () => {
        const count = estimateCheckSlotsNext24h(overnight, 'UTC', 60)
        expect(count).toBeGreaterThan(0)
        expect(count).toBeLessThan(24)
    })

    it('counts fewer 15-minute slots than 96 when quiet hours apply', () => {
        const count = estimateCheckSlotsNext24h(overnight, 'UTC', 15)
        expect(count).toBeGreaterThan(0)
        expect(count).toBeLessThan(96)
    })
})