: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
import { Scope } from '../../scope'
import { JoinExpr } from './join'
import { LiteralExpr } from './literal'
describe('JoinExpr', () => {
const scope = Scope.forNode({}, 'user')
it('joins elements with the given separator', () => {
const expr = new JoinExpr(new LiteralExpr(['a', 'b', 'c']), new LiteralExpr(', '), null)
expect(expr.eval(scope)).toBe('a, b, c')
})
it('plucks a field from each object element when field is set', () => {
const items = [{ text: 'one' }, { text: 'two' }]
const expr = new JoinExpr(new LiteralExpr(items), new LiteralExpr(' / '), new LiteralExpr('text'))
expect(expr.eval(scope)).toBe('one / two')
})
it('returns an empty string for a non-array source', () => {
const expr = new JoinExpr(new LiteralExpr('not an array'), new LiteralExpr(', '), null)
expect(expr.eval(scope)).toBe('')
})
})