From 00ad26c08d8ee7f9ad640ec34c23fcb952d6885d Mon Sep 17 00:00:00 2001 From: Gabriel Horacio Cutrini Date: Thu, 13 Aug 2026 13:40:26 -0300 Subject: [PATCH] Fix the discover integration test against the merged promo hook PR 150 wrote the test against the hook where promoCodeVerified was a prop; PR 151 made acceptance the hook's own state, earned by validating. Merged together, the prop is ignored and the discovered code never counts as active. The test now runs one successful validation, the way the app reaches that state. --- .../discoverPromoCodes.integration.test.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/__tests__/discoverPromoCodes.integration.test.js b/src/__tests__/discoverPromoCodes.integration.test.js index 62d7781..6427bdf 100644 --- a/src/__tests__/discoverPromoCodes.integration.test.js +++ b/src/__tests__/discoverPromoCodes.integration.test.js @@ -21,7 +21,7 @@ * would before dispatching the success action. */ -import { renderHook } from '@testing-library/react-hooks'; +import { renderHook, act } from '@testing-library/react-hooks'; import { createStore, combineReducers, applyMiddleware } from 'redux'; import thunk from 'redux-thunk'; @@ -171,16 +171,21 @@ describe('discoverPromoCodes — request → reducer → hook, end to end', () = const { result } = renderHook(() => usePromoCode({ discoveredPromoCodes, promoCode: 'PRESALE', - promoCodeVerified: true, - promoCodeValidating: false, applyPromoCode: jest.fn(() => Promise.resolve()), removePromoCode: jest.fn(), - validatePromoCode: jest.fn(() => Promise.resolve()), + validatePromoCode: jest.fn(() => Promise.resolve({ response: {} })), setFormPromoCode: jest.fn(), ticketDataLoaded: true, hasTickets: true, })); + // Whether the code was accepted is the hook's own state now, not a + // prop: earn it the way the app does, with one successful validation + // against a qualifying ticket. + await act(async () => { + await result.current.actions.onRevalidate({ id: 202, sub_type: 'Regular' }, 1); + }); + expect(result.current.state.suggestedCode).toBe('PRESALE'); expect(result.current.state.perAccountLimit).toBe(24); expect(result.current.state.maxQuantityFromPromo).toBe(24); // min(remaining_per_account, quantity_available)