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.

604 B
Raw Blame
import { Scope } from '../../scope'
import { PathExpr } from './path'

describe('PathExpr', () => {
    it('reads a nested field by path', () => {
        const scope = Scope.forNode({ message: { content: 'hello' } }, 'user')
        expect(new PathExpr(['message', 'content']).eval(scope)).toBe('hello')
    })

    it('returns undefined when the path is missing', () => {
        const scope = Scope.forNode({ message: {} }, 'user')
        expect(new PathExpr(['message', 'content']).eval(scope)).toBeUndefined()
        expect(new PathExpr(['missing', 'deep']).eval(scope)).toBeUndefined()
    })
})