Refactor: Update FlyerCountDisplay tests to use useFlyers hook and FlyersProvider
All checks were successful
Deploy to Test Environment / deploy-to-test (push) Successful in 7m0s

This commit is contained in:
2025-12-15 00:19:51 -08:00
parent 6e8a8343e0
commit 066933ff6d
15 changed files with 129 additions and 171 deletions

View File

@@ -448,17 +448,18 @@ describe('Flyer DB Service', () => {
describe('deleteFlyer', () => {
it('should use withTransaction to delete a flyer', async () => {
// Create a mock client that we can reference both inside and outside the transaction mock.
const mockClient = { query: vi.fn() };
const mockClientQuery = vi.fn();
vi.mocked(withTransaction).mockImplementation(async (callback) => {
(mockClient.query as Mock).mockResolvedValueOnce({ rowCount: 1 });
const mockClient = { query: mockClientQuery };
mockClientQuery.mockResolvedValueOnce({ rowCount: 1 });
return callback(mockClient as unknown as PoolClient);
});
await flyerRepo.deleteFlyer(42, mockLogger);
expect(withTransaction).toHaveBeenCalledTimes(1);
expect(mockClient.query).toHaveBeenCalledWith('DELETE FROM public.flyers WHERE flyer_id = $1', [42]); // This was a duplicate, fixed.
expect(mockClientQuery).toHaveBeenCalledWith('DELETE FROM public.flyers WHERE flyer_id = $1', [42]);
});
it('should throw an error if the flyer to delete is not found', async () => {