Add ESLint v9.35+ with typescript-eslint recommended config and
error-handling rules: preserve-caught-error (enforces { cause } when
re-throwing), no-unused-vars with caughtErrors:all, and
eslint-plugin-no-catch-all (warns on catch blocks that don't rethrow).
Fix existing violations: add error cause to container-runtime rethrow,
prefix unused vars with underscore, remove unused imports.
https://claude.ai/code/session_01JPjzhBp9PR5LtfLWVDrYrH
43 lines
1.5 KiB
TypeScript
43 lines
1.5 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
|
|
import {
|
|
registerChannel,
|
|
getChannelFactory,
|
|
getRegisteredChannelNames,
|
|
} from './registry.js';
|
|
|
|
// The registry is module-level state, so we need a fresh module per test.
|
|
// We use dynamic import with cache-busting to isolate tests.
|
|
// However, since vitest runs each file in its own context and we control
|
|
// registration order, we can test the public API directly.
|
|
|
|
describe('channel registry', () => {
|
|
// Note: registry is shared module state across tests in this file.
|
|
// Tests are ordered to account for cumulative registrations.
|
|
|
|
it('getChannelFactory returns undefined for unknown channel', () => {
|
|
expect(getChannelFactory('nonexistent')).toBeUndefined();
|
|
});
|
|
|
|
it('registerChannel and getChannelFactory round-trip', () => {
|
|
const factory = () => null;
|
|
registerChannel('test-channel', factory);
|
|
expect(getChannelFactory('test-channel')).toBe(factory);
|
|
});
|
|
|
|
it('getRegisteredChannelNames includes registered channels', () => {
|
|
registerChannel('another-channel', () => null);
|
|
const names = getRegisteredChannelNames();
|
|
expect(names).toContain('test-channel');
|
|
expect(names).toContain('another-channel');
|
|
});
|
|
|
|
it('later registration overwrites earlier one', () => {
|
|
const factory1 = () => null;
|
|
const factory2 = () => null;
|
|
registerChannel('overwrite-test', factory1);
|
|
registerChannel('overwrite-test', factory2);
|
|
expect(getChannelFactory('overwrite-test')).toBe(factory2);
|
|
});
|
|
});
|