Skip to content

Commit e57e2ef

Browse files
committed
fix(tests): apply linter formatting and use optional chaining
Fix linting violations that were preventing CI from passing: 1. test/argv/parse.test.ts: - Use optional chaining with type assertion to satisfy both linter and TypeScript type checker - Cast result.raw['--'] to string[] | undefined before using ?.includes() - Wrap in Boolean() for explicit type conversion - Apply multi-line formatting for readability 2. test/performance.test.ts: - Collapse multi-line it() function to single line as per formatter - Maintain retry logic and comments Both changes preserve functionality while meeting code style requirements.
1 parent 308bcb3 commit e57e2ef

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

test/argv/parse.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ describe('argv/parse', () => {
155155
// Arguments after -- may be in positionals or in the raw['--'] array
156156
const hasFlag =
157157
result.positionals.includes('--not-a-flag') ||
158-
(result.raw['--'] && result.raw['--'].includes('--not-a-flag'))
158+
Boolean(
159+
(result.raw['--'] as string[] | undefined)?.includes('--not-a-flag'),
160+
)
159161
expect(hasFlag).toBe(true)
160162
})
161163

test/performance.test.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,16 @@ describe('performance', () => {
2020
})
2121

2222
describe('basic performance measurements', () => {
23-
it(
24-
'should measure elapsed time',
25-
{ retry: 3 },
26-
async () => {
27-
const start = performance.now()
28-
await new Promise(resolve => setTimeout(resolve, 10))
29-
const end = performance.now()
30-
const elapsed = end - start
31-
expect(elapsed).toBeGreaterThan(0)
32-
// Allow for timer imprecision (9ms threshold instead of 10ms)
33-
// setTimeout is not guaranteed to be exact due to OS scheduling
34-
expect(elapsed).toBeGreaterThanOrEqual(9)
35-
},
36-
)
23+
it('should measure elapsed time', { retry: 3 }, async () => {
24+
const start = performance.now()
25+
await new Promise(resolve => setTimeout(resolve, 10))
26+
const end = performance.now()
27+
const elapsed = end - start
28+
expect(elapsed).toBeGreaterThan(0)
29+
// Allow for timer imprecision (9ms threshold instead of 10ms)
30+
// setTimeout is not guaranteed to be exact due to OS scheduling
31+
expect(elapsed).toBeGreaterThanOrEqual(9)
32+
})
3733

3834
it('should support performance.now()', () => {
3935
const now = performance.now()

0 commit comments

Comments
 (0)