fixed format issues
This commit is contained in:
parent
a700818a06
commit
08f713d98b
55 changed files with 5680 additions and 5533 deletions
|
|
@ -107,14 +107,14 @@ describe('DI Registrations', () => {
|
|||
describe('registerDatabaseServices', () => {
|
||||
it('should register MongoDB when config exists', () => {
|
||||
const container = createContainer();
|
||||
|
||||
|
||||
// Mock MongoDB client
|
||||
const mockMongoClient = {
|
||||
connect: mock(() => Promise.resolve()),
|
||||
disconnect: mock(() => Promise.resolve()),
|
||||
getDb: mock(() => ({})),
|
||||
};
|
||||
|
||||
|
||||
// Mock the MongoDB factory
|
||||
mock.module('@stock-bot/mongodb', () => ({
|
||||
MongoDBClient: class {
|
||||
|
|
@ -123,7 +123,7 @@ describe('DI Registrations', () => {
|
|||
}
|
||||
},
|
||||
}));
|
||||
|
||||
|
||||
const config = {
|
||||
mongodb: {
|
||||
enabled: true,
|
||||
|
|
@ -139,14 +139,14 @@ describe('DI Registrations', () => {
|
|||
|
||||
it('should register PostgreSQL when config exists', () => {
|
||||
const container = createContainer();
|
||||
|
||||
|
||||
// Mock Postgres client
|
||||
const mockPostgresClient = {
|
||||
connect: mock(() => Promise.resolve()),
|
||||
disconnect: mock(() => Promise.resolve()),
|
||||
query: mock(() => Promise.resolve({ rows: [] })),
|
||||
};
|
||||
|
||||
|
||||
// Mock the Postgres factory
|
||||
mock.module('@stock-bot/postgres', () => ({
|
||||
PostgresClient: class {
|
||||
|
|
@ -155,7 +155,7 @@ describe('DI Registrations', () => {
|
|||
}
|
||||
},
|
||||
}));
|
||||
|
||||
|
||||
const config = {
|
||||
postgres: {
|
||||
enabled: true,
|
||||
|
|
@ -174,14 +174,14 @@ describe('DI Registrations', () => {
|
|||
|
||||
it('should register QuestDB when config exists', () => {
|
||||
const container = createContainer();
|
||||
|
||||
|
||||
// Mock QuestDB client
|
||||
const mockQuestdbClient = {
|
||||
connect: mock(() => Promise.resolve()),
|
||||
disconnect: mock(() => Promise.resolve()),
|
||||
query: mock(() => Promise.resolve({ data: [] })),
|
||||
};
|
||||
|
||||
|
||||
// Mock the QuestDB factory
|
||||
mock.module('@stock-bot/questdb', () => ({
|
||||
QuestDBClient: class {
|
||||
|
|
@ -190,7 +190,7 @@ describe('DI Registrations', () => {
|
|||
}
|
||||
},
|
||||
}));
|
||||
|
||||
|
||||
const config = {
|
||||
questdb: {
|
||||
enabled: true,
|
||||
|
|
@ -209,7 +209,7 @@ describe('DI Registrations', () => {
|
|||
|
||||
it('should not register disabled databases', () => {
|
||||
const container = createContainer();
|
||||
|
||||
|
||||
const config = {
|
||||
mongodb: { enabled: false },
|
||||
postgres: { enabled: false },
|
||||
|
|
@ -222,7 +222,7 @@ describe('DI Registrations', () => {
|
|||
expect(container.hasRegistration('mongoClient')).toBe(true);
|
||||
expect(container.hasRegistration('postgresClient')).toBe(true);
|
||||
expect(container.hasRegistration('questdbClient')).toBe(true);
|
||||
|
||||
|
||||
// Verify they resolve to null
|
||||
expect(container.resolve('mongoClient')).toBeNull();
|
||||
expect(container.resolve('postgresClient')).toBeNull();
|
||||
|
|
@ -233,17 +233,17 @@ describe('DI Registrations', () => {
|
|||
describe('registerApplicationServices', () => {
|
||||
it('should register browser when config exists', () => {
|
||||
const container = createContainer();
|
||||
|
||||
|
||||
// Mock browser factory
|
||||
const mockBrowser = {
|
||||
launch: mock(() => Promise.resolve()),
|
||||
close: mock(() => Promise.resolve()),
|
||||
};
|
||||
|
||||
|
||||
mock.module('@stock-bot/browser', () => ({
|
||||
createBrowser: () => mockBrowser,
|
||||
}));
|
||||
|
||||
|
||||
const config = {
|
||||
browser: {
|
||||
headless: true,
|
||||
|
|
@ -258,16 +258,16 @@ describe('DI Registrations', () => {
|
|||
|
||||
it('should register proxy when config exists', () => {
|
||||
const container = createContainer();
|
||||
|
||||
|
||||
// Mock proxy factory
|
||||
const mockProxy = {
|
||||
getProxy: mock(() => 'http://proxy:8080'),
|
||||
};
|
||||
|
||||
|
||||
mock.module('@stock-bot/proxy', () => ({
|
||||
createProxyManager: () => mockProxy,
|
||||
}));
|
||||
|
||||
|
||||
const config = {
|
||||
proxy: {
|
||||
enabled: true,
|
||||
|
|
@ -282,7 +282,7 @@ describe('DI Registrations', () => {
|
|||
|
||||
it('should register queue manager when queue config exists', () => {
|
||||
const container = createContainer();
|
||||
|
||||
|
||||
// Mock dependencies
|
||||
container.register({
|
||||
cache: asValue({
|
||||
|
|
@ -300,14 +300,14 @@ describe('DI Registrations', () => {
|
|||
debug: mock(() => {}),
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
// Mock queue manager
|
||||
const mockQueueManager = {
|
||||
getQueue: mock(() => ({})),
|
||||
startAllWorkers: mock(() => {}),
|
||||
shutdown: mock(() => Promise.resolve()),
|
||||
};
|
||||
|
||||
|
||||
mock.module('@stock-bot/queue', () => ({
|
||||
QueueManager: class {
|
||||
constructor() {
|
||||
|
|
@ -315,7 +315,7 @@ describe('DI Registrations', () => {
|
|||
}
|
||||
},
|
||||
}));
|
||||
|
||||
|
||||
const config = {
|
||||
service: {
|
||||
name: 'test-service',
|
||||
|
|
@ -335,7 +335,7 @@ describe('DI Registrations', () => {
|
|||
|
||||
it('should not register services when configs are missing', () => {
|
||||
const container = createContainer();
|
||||
|
||||
|
||||
const config = {} as any;
|
||||
|
||||
registerApplicationServices(container, config);
|
||||
|
|
@ -343,12 +343,12 @@ describe('DI Registrations', () => {
|
|||
expect(container.hasRegistration('browser')).toBe(true);
|
||||
expect(container.hasRegistration('proxyManager')).toBe(true);
|
||||
expect(container.hasRegistration('queueManager')).toBe(true);
|
||||
|
||||
|
||||
// They should be registered as null
|
||||
const browser = container.resolve('browser');
|
||||
const proxyManager = container.resolve('proxyManager');
|
||||
const queueManager = container.resolve('queueManager');
|
||||
|
||||
|
||||
expect(browser).toBe(null);
|
||||
expect(proxyManager).toBe(null);
|
||||
expect(queueManager).toBe(null);
|
||||
|
|
@ -358,7 +358,7 @@ describe('DI Registrations', () => {
|
|||
describe('dependency resolution', () => {
|
||||
it('should properly resolve cache dependencies', () => {
|
||||
const container = createContainer();
|
||||
|
||||
|
||||
const config = {
|
||||
service: {
|
||||
name: 'test-service',
|
||||
|
|
@ -373,7 +373,7 @@ describe('DI Registrations', () => {
|
|||
} as any;
|
||||
|
||||
registerCacheServices(container, config);
|
||||
|
||||
|
||||
// Should have registered cache
|
||||
expect(container.hasRegistration('cache')).toBe(true);
|
||||
expect(container.hasRegistration('globalCache')).toBe(true);
|
||||
|
|
@ -381,13 +381,13 @@ describe('DI Registrations', () => {
|
|||
|
||||
it('should handle circular dependencies gracefully', () => {
|
||||
const container = createContainer();
|
||||
|
||||
|
||||
// Register services with potential circular deps
|
||||
container.register({
|
||||
serviceA: asFunction(({ serviceB }) => ({ b: serviceB })).singleton(),
|
||||
serviceB: asFunction(({ serviceA }) => ({ a: serviceA })).singleton(),
|
||||
});
|
||||
|
||||
|
||||
// This should throw or handle gracefully
|
||||
expect(() => container.resolve('serviceA')).toThrow();
|
||||
});
|
||||
|
|
@ -396,7 +396,7 @@ describe('DI Registrations', () => {
|
|||
describe('registration options', () => {
|
||||
it('should register services as singletons', () => {
|
||||
const container = createContainer();
|
||||
|
||||
|
||||
const config = {
|
||||
browser: {
|
||||
headless: true,
|
||||
|
|
@ -405,7 +405,7 @@ describe('DI Registrations', () => {
|
|||
} as any;
|
||||
|
||||
registerApplicationServices(container, config);
|
||||
|
||||
|
||||
// Check that browser was registered as singleton
|
||||
const registration = container.getRegistration('browser');
|
||||
expect(registration).toBeDefined();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue