added cli-covarage tool and fixed more tests
This commit is contained in:
parent
b63e58784c
commit
b845a8eade
57 changed files with 11917 additions and 295 deletions
78
libs/core/handlers/test/auto-register-simple.test.ts
Normal file
78
libs/core/handlers/test/auto-register-simple.test.ts
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
import { describe, it, expect, beforeEach, afterEach, mock } from 'bun:test';
|
||||
import { autoRegisterHandlers, createAutoHandlerRegistry } from '../src/registry/auto-register';
|
||||
import { BaseHandler } from '../src/base/BaseHandler';
|
||||
import type { IServiceContainer } from '@stock-bot/types';
|
||||
|
||||
describe('Auto Registration - Simple Tests', () => {
|
||||
describe('autoRegisterHandlers', () => {
|
||||
it('should return empty results for non-existent directory', async () => {
|
||||
const mockServices = {} as IServiceContainer;
|
||||
const result = await autoRegisterHandlers('./non-existent-directory', mockServices);
|
||||
|
||||
expect(result.registered).toEqual([]);
|
||||
expect(result.failed).toEqual([]);
|
||||
});
|
||||
|
||||
it('should handle directory with no handler files', async () => {
|
||||
const mockServices = {} as IServiceContainer;
|
||||
// Use the test directory itself which has no handler files
|
||||
const result = await autoRegisterHandlers('./test', mockServices);
|
||||
|
||||
expect(result.registered).toEqual([]);
|
||||
expect(result.failed).toEqual([]);
|
||||
});
|
||||
|
||||
it('should support dry run mode', async () => {
|
||||
const mockServices = {} as IServiceContainer;
|
||||
const result = await autoRegisterHandlers('./non-existent', mockServices, { dryRun: true });
|
||||
|
||||
expect(result.registered).toEqual([]);
|
||||
expect(result.failed).toEqual([]);
|
||||
});
|
||||
|
||||
it('should handle excluded patterns', async () => {
|
||||
const mockServices = {} as IServiceContainer;
|
||||
const result = await autoRegisterHandlers('./test', mockServices, {
|
||||
exclude: ['test']
|
||||
});
|
||||
|
||||
expect(result.registered).toEqual([]);
|
||||
expect(result.failed).toEqual([]);
|
||||
});
|
||||
|
||||
it('should accept custom pattern', async () => {
|
||||
const mockServices = {} as IServiceContainer;
|
||||
const result = await autoRegisterHandlers('./test', mockServices, {
|
||||
pattern: '.custom.'
|
||||
});
|
||||
|
||||
expect(result.registered).toEqual([]);
|
||||
expect(result.failed).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('createAutoHandlerRegistry', () => {
|
||||
it('should create registry with registerDirectory method', () => {
|
||||
const mockServices = {} as IServiceContainer;
|
||||
const registry = createAutoHandlerRegistry(mockServices);
|
||||
|
||||
expect(registry).toHaveProperty('registerDirectory');
|
||||
expect(registry).toHaveProperty('registerDirectories');
|
||||
expect(typeof registry.registerDirectory).toBe('function');
|
||||
expect(typeof registry.registerDirectories).toBe('function');
|
||||
});
|
||||
|
||||
it('should register from multiple directories', async () => {
|
||||
const mockServices = {} as IServiceContainer;
|
||||
const registry = createAutoHandlerRegistry(mockServices);
|
||||
|
||||
const result = await registry.registerDirectories([
|
||||
'./non-existent-1',
|
||||
'./non-existent-2'
|
||||
]);
|
||||
|
||||
expect(result.registered).toEqual([]);
|
||||
expect(result.failed).toEqual([]);
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue