11import { render , waitFor } from '@testing-library/react' ;
22import { pickMessage } from '../lib/messagePicker' ;
3+ import { useAB } from '../lib/useAB' ;
34import { useCountryCode } from '../lib/useCountryCode' ;
45import { ConfigProvider } from './ConfigContext' ;
56import { SlotBodyEnd } from './SlotBodyEnd.island' ;
@@ -34,7 +35,9 @@ jest.mock('../lib/useBraze', () => ({
3435} ) ) ;
3536
3637jest . mock ( '../lib/useAB' , ( ) => ( {
37- useAB : jest . fn ( ) . mockReturnValue ( null ) ,
38+ useAB : jest . fn ( ) . mockReturnValue ( {
39+ isUserInTestGroup : jest . fn ( ) . mockReturnValue ( false ) ,
40+ } ) ,
3841} ) ) ;
3942
4043jest . mock ( '../lib/braze/BrazeBannersSystem' , ( ) => ( {
@@ -95,6 +98,15 @@ const renderSlotBodyEnd = (props: Partial<typeof defaultProps> = {}) =>
9598
9699const mockPickMessage = jest . mocked ( pickMessage ) ;
97100const mockUseCountryCode = jest . mocked ( useCountryCode ) ;
101+ const mockUseAB = jest . mocked ( useAB ) ;
102+
103+ const mockInArticleEndHeaderBiddingTest = ( ) => {
104+ mockUseAB . mockReturnValue ( {
105+ isUserInTestGroup : ( testId : string , groupId : string ) =>
106+ testId === 'commercial-article-end-header-bidding' &&
107+ groupId === 'variant' ,
108+ } as ReturnType < typeof useAB > ) ;
109+ } ;
98110
99111describe ( 'SlotBodyEnd' , ( ) => {
100112 afterEach ( ( ) => {
@@ -134,8 +146,8 @@ describe('SlotBodyEnd', () => {
134146 type : 'NoMessageSelected' ,
135147 } ) ;
136148
137- // showPublicGood requires countryCode === 'US'
138149 mockUseCountryCode . mockReturnValue ( 'US' ) ;
150+ mockInArticleEndHeaderBiddingTest ( ) ;
139151
140152 const { findByTestId } = renderSlotBodyEnd ( {
141153 renderAds : true ,
@@ -151,6 +163,7 @@ describe('SlotBodyEnd', () => {
151163 } ) ;
152164
153165 mockUseCountryCode . mockReturnValue ( 'US' ) ;
166+ mockInArticleEndHeaderBiddingTest ( ) ;
154167
155168 const dispatchEventSpy = jest . spyOn ( document , 'dispatchEvent' ) ;
156169
0 commit comments