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.

658 B
Raw Blame
import { EveryPredicate } from './every'
import { IsPredicate } from './is'

describe('EveryPredicate', () => {
    const allStrings = new EveryPredicate(new IsPredicate(['string']))

    it('true when every element satisfies the inner predicate', () => {
        expect(allStrings.test(['a', 'b', 'c'], true)).toBe(true)
    })

    it('false when any element fails the inner predicate', () => {
        expect(allStrings.test(['a', 2, 'c'], true)).toBe(false)
    })

    it('false for an empty array or a non-array', () => {
        expect(allStrings.test([], true)).toBe(false)
        expect(allStrings.test('not an array', true)).toBe(false)
    })
})