mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-22 15:06:32 +00:00
refactor(nest): inject DatabaseService in db-using controllers
This commit is contained in:
@@ -17,6 +17,8 @@ vi.mock('../../../src/db/database', () => ({
|
||||
db: { prepare: () => ({ get: (entryId: number) => entryJourney(entryId) }) },
|
||||
canAccessTrip: vi.fn(),
|
||||
}));
|
||||
import { db as dbConn } from '../../../src/db/database';
|
||||
import { DatabaseService } from '../../../src/nest/database/database.service';
|
||||
vi.mock('../../../src/services/journeyService', () => ({ canAccessJourney }));
|
||||
vi.mock('../../../src/services/adminService', () => ({ isAddonEnabled }));
|
||||
vi.mock('../../../src/nest/plugins/kill-switch', () => ({ pluginsEnabled }));
|
||||
@@ -31,7 +33,7 @@ function controller(invoke: (id: string) => unknown, providers = ['p1']) {
|
||||
providersOf: vi.fn(() => providers),
|
||||
invokeHook: vi.fn(async (id: string) => invoke(id)),
|
||||
} as unknown as PluginRuntimeService;
|
||||
return { c: new JournalEntryRowsController(runtime), runtime };
|
||||
return { c: new JournalEntryRowsController(runtime, new DatabaseService(dbConn)), runtime };
|
||||
}
|
||||
const row = (over: Record<string, unknown> = {}) => ({ label: 'Distance', value: '12 km', ...over });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user