test(lint): reduce warning debt in selected test suites
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { systemInfoTool } from './system-info.js';
|
||||
|
||||
function getOutput(output: string | undefined): string {
|
||||
if (!output) {
|
||||
throw new Error('Expected output');
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
describe('system.info tool', () => {
|
||||
// ── Metadata ─────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -17,14 +24,14 @@ describe('system.info tool', () => {
|
||||
|
||||
expect(result.success).toBe(true);
|
||||
expect(typeof result.output).toBe('string');
|
||||
expect(result.output!.length).toBeGreaterThan(0);
|
||||
expect(getOutput(result.output).length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('output contains expected fields', async () => {
|
||||
const result = await systemInfoTool.execute({});
|
||||
|
||||
expect(result.success).toBe(true);
|
||||
const output = result.output!;
|
||||
const output = getOutput(result.output);
|
||||
|
||||
const expectedFields = [
|
||||
'Date:',
|
||||
@@ -46,17 +53,17 @@ describe('system.info tool', () => {
|
||||
const result = await systemInfoTool.execute({});
|
||||
|
||||
expect(result.success).toBe(true);
|
||||
const output = result.output!;
|
||||
const output = getOutput(result.output);
|
||||
|
||||
// Find the line containing 'ISO 8601:'
|
||||
const isoLine = output.split('\n').find((line) => line.includes('ISO 8601:'));
|
||||
expect(isoLine).toBeTruthy();
|
||||
|
||||
// Extract the ISO string and validate it
|
||||
const isoMatch = isoLine!.match(/ISO 8601:\s*(.+)/);
|
||||
const isoMatch = getOutput(isoLine).match(/ISO 8601:\s*(.+)/);
|
||||
expect(isoMatch).toBeTruthy();
|
||||
|
||||
const isoString = isoMatch![1].trim();
|
||||
const isoString = getOutput(isoMatch?.[1]).trim();
|
||||
const parsed = new Date(isoString);
|
||||
expect(parsed.toISOString()).toBe(isoString);
|
||||
});
|
||||
@@ -78,7 +85,7 @@ describe('system.info tool', () => {
|
||||
expect(result2.success).toBe(true);
|
||||
expect(typeof result1.output).toBe('string');
|
||||
expect(typeof result2.output).toBe('string');
|
||||
expect(result1.output!.length).toBeGreaterThan(0);
|
||||
expect(result2.output!.length).toBeGreaterThan(0);
|
||||
expect(getOutput(result1.output).length).toBeGreaterThan(0);
|
||||
expect(getOutput(result2.output).length).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user