Skip to content

Commit cbda17a

Browse files
committed
chore: add some coverage back
1 parent 6234de3 commit cbda17a

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

e2e/scan/eol.test.ts

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,25 @@ describe('scan:eol e2e', () => {
165165
doesNotThrow(() => JSON.parse(stdout));
166166
});
167167

168-
it('correctly identifies Angular 17 as having a EOL date and remediations available', async () => {
168+
it('correctly identifies Bootstrap as having EOL status and remediation available when using the --json flag', async () => {
169+
const cmd = `scan:eol --purls=${simplePurls} --json`;
170+
const { stdout } = await run(cmd);
171+
172+
const json = JSON.parse(stdout);
173+
const bootstrap = json.components.find((component) => component.purl.startsWith('pkg:npm/bootstrap@'));
174+
strictEqual(bootstrap?.info.status, 'EOL', 'Should match EOL count');
175+
strictEqual(bootstrap?.info.nesAvailable, true, 'Should match remediation count');
176+
});
177+
178+
it('correctly identifies Angular 17 as having a EOL date when using --json flag', async () => {
169179
const angular17Purls = path.resolve(__dirname, '../fixtures/npm/angular-17.purls.json');
170-
const cmd = `scan:eol --purls=${angular17Purls}`;
180+
const cmd = `scan:eol --purls=${angular17Purls} --json`;
171181
const { stdout } = await run(cmd);
172182

183+
const json = JSON.parse(stdout);
184+
const angular17 = json.components.find((component) => component.purl.startsWith('pkg:npm/%40angular/core@'));
173185
// Match EOL count
174-
match(stdout, /1( .*)End-of-Life \(EOL\)/, 'Should show EOL count');
175-
match(stdout, /1( .*)HeroDevs NES Remediations Available/, 'Should show remediation count');
186+
strictEqual(angular17?.info.status, 'EOL', 'Should match EOL status');
176187
});
177188

178189
describe('web report URL', () => {
@@ -183,14 +194,22 @@ describe('scan:eol e2e', () => {
183194
// Match the key text and scan ID pattern
184195
match(stdout, /View your full EOL report at.*[a-zA-Z0-9-]+/, 'Should show web report text and scan ID');
185196
});
197+
198+
it('does not display web report URL when using --json flag', async () => {
199+
const cmd = `scan:eol --purls=${simplePurls} --json`;
200+
const { stdout } = await run(cmd);
201+
202+
// Verify URL text is not in output
203+
doesNotMatch(stdout, /View your free EOL report/, 'Should not show web report text in JSON output');
204+
});
186205
});
187206
});
188207

189208
/**
190209
* Directory scan tests
191210
* Please see CONTRIBUTING.md before adding new tests to this section.
192211
*/
193-
describe('scan:eol e2e directory', () => {
212+
describe('with directory flag', () => {
194213
const __dirname = path.dirname(fileURLToPath(import.meta.url));
195214
const simpleDir = path.resolve(__dirname, '../fixtures/npm/simple');
196215
const upToDateDir = path.resolve(__dirname, '../fixtures/npm/up-to-date');

0 commit comments

Comments
 (0)