Skip to content

Commit 0e24f19

Browse files
test(ui): add coverage for maintenance, high/moderate/low vuln branches
1 parent e2cc7e0 commit 0e24f19

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/nuxt/composables/use-package-comparison.spec.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,34 @@ describe('usePackageComparison', () => {
194194
expect(score).toBeGreaterThanOrEqual(0)
195195
expect(score).toBeLessThanOrEqual(100)
196196
})
197+
198+
it('applies lower maintenance score for packages older than 1 year', () => {
199+
const old = new Date()
200+
old.setFullYear(old.getFullYear() - 2)
201+
const score = computeHealthScore(makeData({ metadata: { lastUpdated: old.toISOString() } }))
202+
expect(score).toBeGreaterThanOrEqual(0)
203+
expect(score).toBeLessThanOrEqual(100)
204+
})
205+
206+
it('applies partial security score for high/moderate vulnerabilities', () => {
207+
const high = computeHealthScore(
208+
makeData({
209+
vulnerabilities: { count: 1, severity: { critical: 0, high: 1, moderate: 0, low: 0 } },
210+
}),
211+
)
212+
const moderate = computeHealthScore(
213+
makeData({
214+
vulnerabilities: { count: 1, severity: { critical: 0, high: 0, moderate: 1, low: 0 } },
215+
}),
216+
)
217+
const low = computeHealthScore(
218+
makeData({
219+
vulnerabilities: { count: 1, severity: { critical: 0, high: 0, moderate: 0, low: 0 } },
220+
}),
221+
)
222+
expect(high).toBeLessThan(low)
223+
expect(moderate).toBeGreaterThan(high)
224+
})
197225
})
198226

199227
describe('staleness detection', () => {

0 commit comments

Comments
 (0)