: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 { formatPreviewCell } from './previewCell'
describe('formatPreviewCell', () => {
it.each<[string, unknown, string]>([
['a string', 'orders', 'orders'],
['a number', 42, '42'],
['a boolean', false, 'false'],
['null as empty', null, ''],
['undefined as empty', undefined, ''],
['an array', [1, 2], '[1,2]'],
['an object', { id: 7 }, '{"id":7}'],
// A raw object like this would otherwise reach LemonTable and inject markup via its props.
[
'a cell-representation shape',
{ props: { dangerouslySetInnerHTML: { __html: '<img src=x onerror=alert(1)>' } } },
'{"props":{"dangerouslySetInnerHTML":{"__html":"<img src=x onerror=alert(1)>"}}}',
],
])('renders %s as text', (_case, value, expected) => {
expect(formatPreviewCell(value)).toEqual(expected)
})
})