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
All checks were successful
Deploy to Test Environment / deploy-to-test (push) Successful in 7m0s
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user