scripts/render-review-state.test.mjs
scripts/render-review-state.test.mjsBrowse 11 files
623 tokens
2,402 bytes
Token encoding: o200k_base
Snapshot fac8604
← Back to SKILL.md
1import assert from 'node:assert/strict';2import test from 'node:test';3import { renderReviewStateMarkdown } from './render-review-state.mjs';4 5function buildPayload() {6 return {7 version: 2,8 fetchedAt: '2026-01-01T00:00:00Z',9 sourceBranch: 'main',10 pr: { nodeId: 'PR_1', url: 'https://example.com/pr/1' },11 reviewThreads: [12 {13 threadKey: 'thread:THREAD_1',14 nodeId: 'THREAD_1',15 path: 'docs/a \\| b.md',16 isResolved: false,17 isOutdated: false,18 ordering: {},19 targetHint: { kind: 'review_thread', nodeId: 'THREAD_1' },20 isActionableCandidate: true,21 comments: [22 {23 nodeId: 'COMMENT_1',24 url: 'https://example.com/pr/1#discussion_r1',25 author: { login: 'reviewer' },26 createdAt: '2026-01-01T00:00:00Z',27 body: 'note ends with \\',28 reactionGroups: [],29 },30 ],31 },32 ],33 reviews: [],34 issueComments: [],35 targets: [],36 };37}38 39test('escapes backslashes before pipes in table cells', () => {40 const markdown = renderReviewStateMarkdown(buildPayload(), {41 sourcePath: 'wip/review-state.json',42 });43 44 assert.ok(45 markdown.includes('| THREAD_1 | docs/a \\\\\\| b.md | | no | 1 | note ends with \\\\ |'),46 `expected escaped table row in:\n${markdown}`,47 );48});49 50test('renders sourcePath in the Source code span with literal backslashes and escaped pipes', () => {51 const markdown = renderReviewStateMarkdown(buildPayload(), {52 sourcePath: 'wip\\re|views\\review-state.json',53 });54 55 assert.ok(56 markdown.includes('Source: `wip\\re\\|views\\review-state.json`'),57 `expected code-span source in:\n${markdown}`,58 );59});60 61test('renders sourcePath containing a backtick as an intact code span', () => {62 const markdown = renderReviewStateMarkdown(buildPayload(), {63 sourcePath: 'wip/a`b/review-state.json',64 });65 66 assert.ok(67 markdown.includes('Source: ``wip/a`b/review-state.json``'),68 `expected fenced code-span source in:\n${markdown}`,69 );70});71 72test('pads the code span when sourcePath starts and ends with a backtick', () => {73 const markdown = renderReviewStateMarkdown(buildPayload(), {74 sourcePath: '`review-state.json`',75 });76 77 assert.ok(78 markdown.includes('Source: `` `review-state.json` ``'),79 `expected padded code-span source in:\n${markdown}`,80 );81});82