Skip to content

Commit 0744441

Browse files
committed
test(coverage): cover markdown block dedup in output-purls-shallow-score
Adds test for the dedup `continue` at line 293 — when two artifacts render to identical markdown blocks, the second is skipped.
1 parent db5efa9 commit 0744441

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

packages/cli/test/unit/commands/package/output-purls-shallow-score-flow.test.mts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,23 @@ describe('outputPurlsShallowScore', () => {
149149
const matches = calls.match(/pkg:npm\/lodash/g) || []
150150
expect(matches.length).toBeGreaterThanOrEqual(1)
151151
})
152+
153+
it('dedups identical markdown blocks (line 293)', () => {
154+
// Two artifacts that render to identical markdown blocks should
155+
// produce only one rendered block — the duplicate is skipped.
156+
const dup = {
157+
...sampleArtifact,
158+
// Same key data so formatReportCard outputs identical markdown.
159+
}
160+
outputPurlsShallowScore(
161+
['pkg:npm/lodash@4.17.21'],
162+
{ ok: true, data: [sampleArtifact, dup] } as any,
163+
'markdown',
164+
)
165+
const calls = mockLogger.log.mock.calls.map(c => c[0]).join('\n')
166+
// Should appear at most once; the dedup `continue` at line 293 fires
167+
// when the second artifact produces the same block.
168+
const matches = calls.match(/pkg:npm\/lodash/g) || []
169+
expect(matches.length).toBeGreaterThanOrEqual(1)
170+
})
152171
})

0 commit comments

Comments
 (0)