From 9a476d9b86b4b2e1c73865c64c943cdbf9061e94 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Wed, 30 Sep 2026 09:41:28 -0400 Subject: [PATCH] Add import and use of Pool from pg --- api/src/category.router.test.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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();