Skip to content

Commit 329f74f

Browse files
committed
linting and test fixes
1 parent 1f02783 commit 329f74f

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ program
5656
.option('-x, --exclude <ids>', 'Exceptions or the vulnerabilities ID(s) to exclude.')
5757
.option('-m, --module-ignore <moduleNames>', 'Names of modules to ignore.')
5858
.option('-l, --level <auditLevel>', 'The minimum audit level to validate.')
59-
.option('-f, --filter-table [level]', 'Filter table to show only vulnerabilities at or above specified level (defaults to audit level if no value provided).')
59+
.option(
60+
'-f, --filter-table [level]',
61+
'Filter table to show only vulnerabilities at or above specified level (defaults to audit level if no value provided).',
62+
)
6063
.option('-p, --production', 'Skip checking the devDependencies.')
6164
.option('-r, --registry <url>', 'The npm registry url to use.')
6265
.option('-i, --include-columns <columnName1>,<columnName2>,..,<columnNameN>', 'Columns to include in report.')

test/utils/color.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@ import { expect } from 'chai';
22
import { color, getSeverityBgColor } from '../../src/utils/color';
33

44
describe('Color utils', () => {
5+
let originalNoColor: string | undefined;
6+
7+
before(() => {
8+
originalNoColor = process.env.NO_COLOR;
9+
delete process.env.NO_COLOR;
10+
});
11+
12+
after(() => {
13+
if (originalNoColor !== undefined) {
14+
process.env.NO_COLOR = originalNoColor;
15+
} else {
16+
delete process.env.NO_COLOR;
17+
}
18+
});
19+
520
describe('#color', () => {
621
it('should handle correctly without given colors specificed', () => {
722
expect(color('message')).to.equal('message\u001b[0m');

test/utils/vulnerability.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,22 @@ import V7_JSON_BUFFER_EMPTY from '../__mocks__/v7-json-buffer-empty.json';
2121
import { v6Advisory, v7VulnerabilityVia } from '../../src/types';
2222

2323
describe('Vulnerability utils', () => {
24+
let originalNoColor: string | undefined;
25+
26+
before(() => {
27+
// Ensure color codes are enabled to match fixtures
28+
originalNoColor = process.env.NO_COLOR;
29+
delete process.env.NO_COLOR;
30+
});
31+
32+
after(() => {
33+
if (originalNoColor !== undefined) {
34+
process.env.NO_COLOR = originalNoColor;
35+
} else {
36+
delete process.env.NO_COLOR;
37+
}
38+
});
39+
2440
describe('validateV6Vulnerability', () => {
2541
it('should be able to validate an exception by ID', () => {
2642
const v6Advisory: v6Advisory = {
@@ -152,6 +168,17 @@ describe('Vulnerability utils', () => {
152168
});
153169

154170
describe('#processExceptions', () => {
171+
let clock: sinon.SinonFakeTimers;
172+
173+
before(() => {
174+
// Freeze "now" so date-based coloring (e.g., 2030 expiries) stays deterministic
175+
clock = sinon.useFakeTimers(new Date('2024-01-01T00:00:00Z').getTime());
176+
});
177+
178+
after(() => {
179+
clock.restore();
180+
});
181+
155182
it('should be able to process exceptions correctly', () => {
156183
const cmdExceptions = ['1165', '1890'];
157184
const result = processExceptions(NSPRC, cmdExceptions);

0 commit comments

Comments
 (0)