fixed format issues
This commit is contained in:
parent
a700818a06
commit
08f713d98b
55 changed files with 5680 additions and 5533 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import { describe, it, expect, beforeEach, mock } from 'bun:test';
|
||||
import { autoRegisterHandlers, createAutoHandlerRegistry } from '../src/registry/auto-register';
|
||||
import { BaseHandler } from '../src/base/BaseHandler';
|
||||
import { beforeEach, describe, expect, it, mock } from 'bun:test';
|
||||
import type { IServiceContainer } from '@stock-bot/types';
|
||||
import { BaseHandler } from '../src/base/BaseHandler';
|
||||
import { autoRegisterHandlers, createAutoHandlerRegistry } from '../src/registry/auto-register';
|
||||
|
||||
describe('Auto Registration', () => {
|
||||
describe('autoRegisterHandlers', () => {
|
||||
|
|
@ -9,7 +9,7 @@ describe('Auto Registration', () => {
|
|||
const mockServices = {} as IServiceContainer;
|
||||
// Using a directory that doesn't exist - the function handles this gracefully
|
||||
const result = await autoRegisterHandlers('./non-existent', mockServices);
|
||||
|
||||
|
||||
expect(result).toHaveProperty('registered');
|
||||
expect(result).toHaveProperty('failed');
|
||||
expect(result.registered).toEqual([]);
|
||||
|
|
@ -19,7 +19,7 @@ describe('Auto Registration', () => {
|
|||
it('should use default options when not provided', async () => {
|
||||
const mockServices = {} as IServiceContainer;
|
||||
const result = await autoRegisterHandlers('./test', mockServices);
|
||||
|
||||
|
||||
expect(result).toBeDefined();
|
||||
expect(result.registered).toBeInstanceOf(Array);
|
||||
expect(result.failed).toBeInstanceOf(Array);
|
||||
|
|
@ -27,7 +27,7 @@ describe('Auto Registration', () => {
|
|||
|
||||
it('should handle directory not found gracefully', async () => {
|
||||
const mockServices = {} as IServiceContainer;
|
||||
|
||||
|
||||
// Should not throw for non-existent directory
|
||||
const result = await autoRegisterHandlers('./non-existent-directory', mockServices);
|
||||
expect(result.registered).toEqual([]);
|
||||
|
|
@ -39,7 +39,7 @@ describe('Auto Registration', () => {
|
|||
it('should create a registry with registerDirectory method', () => {
|
||||
const mockServices = {} as IServiceContainer;
|
||||
const registry = createAutoHandlerRegistry(mockServices);
|
||||
|
||||
|
||||
expect(registry).toHaveProperty('registerDirectory');
|
||||
expect(typeof registry.registerDirectory).toBe('function');
|
||||
});
|
||||
|
|
@ -47,7 +47,7 @@ describe('Auto Registration', () => {
|
|||
it('should register from a directory', async () => {
|
||||
const mockServices = {} as IServiceContainer;
|
||||
const registry = createAutoHandlerRegistry(mockServices);
|
||||
|
||||
|
||||
const result = await registry.registerDirectory('./non-existent-dir');
|
||||
expect(result).toHaveProperty('registered');
|
||||
expect(result).toHaveProperty('failed');
|
||||
|
|
@ -56,7 +56,7 @@ describe('Auto Registration', () => {
|
|||
it('should register from multiple directories', async () => {
|
||||
const mockServices = {} as IServiceContainer;
|
||||
const registry = createAutoHandlerRegistry(mockServices);
|
||||
|
||||
|
||||
const result = await registry.registerDirectories(['./dir1', './dir2']);
|
||||
expect(result).toHaveProperty('registered');
|
||||
expect(result).toHaveProperty('failed');
|
||||
|
|
@ -68,7 +68,7 @@ describe('Auto Registration', () => {
|
|||
describe('Edge Cases', () => {
|
||||
it('should handle non-existent directories gracefully', async () => {
|
||||
const mockServices = {} as any;
|
||||
|
||||
|
||||
// Should not throw, just return empty results
|
||||
const result = await autoRegisterHandlers('./definitely-does-not-exist-12345', mockServices);
|
||||
expect(result.registered).toEqual([]);
|
||||
|
|
@ -77,7 +77,7 @@ describe('Auto Registration', () => {
|
|||
|
||||
it('should handle empty options', async () => {
|
||||
const mockServices = {} as any;
|
||||
|
||||
|
||||
// Should use default options
|
||||
const result = await autoRegisterHandlers('./test', mockServices, {});
|
||||
expect(result).toBeDefined();
|
||||
|
|
@ -87,18 +87,18 @@ describe('Auto Registration', () => {
|
|||
|
||||
it('should support service name in options', async () => {
|
||||
const mockServices = {} as any;
|
||||
|
||||
|
||||
const result = await autoRegisterHandlers('./test', mockServices, {
|
||||
serviceName: 'test-service'
|
||||
serviceName: 'test-service',
|
||||
});
|
||||
|
||||
|
||||
expect(result).toBeDefined();
|
||||
});
|
||||
|
||||
it('should handle dry run mode', async () => {
|
||||
const mockServices = {} as any;
|
||||
const result = await autoRegisterHandlers('./test', mockServices, { dryRun: true });
|
||||
|
||||
|
||||
expect(result).toBeDefined();
|
||||
expect(result.registered).toBeInstanceOf(Array);
|
||||
expect(result.failed).toBeInstanceOf(Array);
|
||||
|
|
@ -106,10 +106,10 @@ describe('Auto Registration', () => {
|
|||
|
||||
it('should handle excluded files', async () => {
|
||||
const mockServices = {} as any;
|
||||
const result = await autoRegisterHandlers('./test', mockServices, {
|
||||
exclude: ['test']
|
||||
const result = await autoRegisterHandlers('./test', mockServices, {
|
||||
exclude: ['test'],
|
||||
});
|
||||
|
||||
|
||||
expect(result).toBeDefined();
|
||||
expect(result.registered).toBeInstanceOf(Array);
|
||||
expect(result.failed).toBeInstanceOf(Array);
|
||||
|
|
@ -118,7 +118,7 @@ describe('Auto Registration', () => {
|
|||
it('should handle custom pattern', async () => {
|
||||
const mockServices = {} as any;
|
||||
const result = await autoRegisterHandlers('./test', mockServices, { pattern: '.custom.' });
|
||||
|
||||
|
||||
expect(result).toBeDefined();
|
||||
expect(result.registered).toBeInstanceOf(Array);
|
||||
expect(result.failed).toBeInstanceOf(Array);
|
||||
|
|
@ -126,13 +126,13 @@ describe('Auto Registration', () => {
|
|||
|
||||
it('should handle errors gracefully', async () => {
|
||||
const mockServices = {} as any;
|
||||
|
||||
|
||||
// Even with a protected directory, it should handle gracefully
|
||||
const result = await autoRegisterHandlers('./protected-dir', mockServices);
|
||||
|
||||
|
||||
expect(result).toBeDefined();
|
||||
expect(result.registered).toBeInstanceOf(Array);
|
||||
expect(result.failed).toBeInstanceOf(Array);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue