(t, added, removed, changed, audited, json, command)
| 289 | t.test('packages changed message', async t => { |
| 290 | // return a test function that builds up the mock and snapshots output |
| 291 | const testCase = async (t, added, removed, changed, audited, json, command) => { |
| 292 | const mock = { |
| 293 | actualTree: { |
| 294 | inventory: { size: audited, has: () => true }, |
| 295 | children: [], |
| 296 | }, |
| 297 | auditReport: audited ? { |
| 298 | toJSON: () => mock.auditReport, |
| 299 | vulnerabilities: {}, |
| 300 | metadata: { |
| 301 | vulnerabilities: { |
| 302 | total: 0, |
| 303 | }, |
| 304 | }, |
| 305 | } : null, |
| 306 | diff: { |
| 307 | children: [ |
| 308 | { action: 'some random unexpected junk' }, |
| 309 | ], |
| 310 | }, |
| 311 | } |
| 312 | for (let i = 0; i < added; i++) { |
| 313 | mock.diff.children.push({ action: 'ADD', ideal: { path: `test/${i}`, name: `@npmcli/pkg${i}`, location: 'loc', package: { version: `1.0.${i}` } } }) |
| 314 | } |
| 315 | |
| 316 | for (let i = 0; i < removed; i++) { |
| 317 | mock.diff.children.push({ action: 'REMOVE', actual: { path: `test/${i}`, name: `@npmcli/pkg${i}`, location: 'loc', package: { version: `1.0.${i}` } } }) |
| 318 | } |
| 319 | |
| 320 | for (let i = 0; i < changed; i++) { |
| 321 | const actual = { path: `test/a/${i}`, name: `@npmcli/pkg${i}`, location: 'loc', package: { version: `1.0.${i}` } } |
| 322 | const ideal = { path: `test/i/${i}`, name: `@npmcli/pkg${i}`, location: 'loc', package: { version: `1.1.${i}` } } |
| 323 | mock.diff.children.push({ action: 'CHANGE', actual, ideal }) |
| 324 | } |
| 325 | |
| 326 | const out = await mockReify(t, mock, { json, command }) |
| 327 | t.matchSnapshot(out, JSON.stringify({ |
| 328 | added, |
| 329 | removed, |
| 330 | changed, |
| 331 | audited, |
| 332 | json, |
| 333 | })) |
| 334 | } |
| 335 | |
| 336 | const cases = [] |
| 337 | for (const added of [0, 1, 2]) { |
no test coverage detected
searching dependent graphs…