diff --git a/api/src/category.router.test.ts b/api/src/category.router.test.ts index 2886882..c9266e7 100644 --- a/api/src/category.router.test.ts +++ b/api/src/category.router.test.ts @@ -1,5 +1,6 @@ import { describe, it } from 'node:test'; import assert from 'node:assert/strict'; +import { Pool } from 'pg'; import { createCategoryRouter } from './category.router.ts'; import { CategoryRepository } from './category.repository.ts'; import { Request, Response } from 'express'; @@ -45,11 +46,15 @@ function getRouteHandler(router: any): Function { return routeLayer.route.stack[0].handle; // Target the primary callback handler array element } +const pool = new Pool({ + connectionString: process.env.DATABASE_URL || process.env.INTERNAL_PROD_DB_URL +}); + describe('Category Router Endpoints', () => { it('GET /tree{/:path} - should return 200 and structural JSON array data on valid requests', async () => { const mockRepo = createMockRepository('success'); - const router = createCategoryRouter(mockRepo); + const router = createCategoryRouter(mockRepo, pool); const mockReq = { params: { path: 'Top' } } as unknown as Request; const { mockRes, data } = createMockResponse(); @@ -67,7 +72,7 @@ describe('Category Router Endpoints', () => { it('GET /tree{/:path} - should return 400 Bad Request if ltree path contains malformed formatting', async () => { const mockRepo = createMockRepository('success'); - const router = createCategoryRouter(mockRepo); + const router = createCategoryRouter(mockRepo, pool); const mockReq = { params: { path: 'Top.Bad Path!' } } as unknown as Request; const { mockRes, data } = createMockResponse();