Skip to content

Commit d3f81e3

Browse files
committed
Update unit tests based on the changes
1 parent 128fad6 commit d3f81e3

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

dotcom-rendering/src/components/SlotBodyEnd.island.test.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { render, waitFor } from '@testing-library/react';
22
import { pickMessage } from '../lib/messagePicker';
3+
import { useAB } from '../lib/useAB';
34
import { useCountryCode } from '../lib/useCountryCode';
45
import { ConfigProvider } from './ConfigContext';
56
import { SlotBodyEnd } from './SlotBodyEnd.island';
@@ -34,7 +35,9 @@ jest.mock('../lib/useBraze', () => ({
3435
}));
3536

3637
jest.mock('../lib/useAB', () => ({
37-
useAB: jest.fn().mockReturnValue(null),
38+
useAB: jest.fn().mockReturnValue({
39+
isUserInTestGroup: jest.fn().mockReturnValue(false),
40+
}),
3841
}));
3942

4043
jest.mock('../lib/braze/BrazeBannersSystem', () => ({
@@ -95,6 +98,15 @@ const renderSlotBodyEnd = (props: Partial<typeof defaultProps> = {}) =>
9598

9699
const mockPickMessage = jest.mocked(pickMessage);
97100
const 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

99111
describe('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

Comments
 (0)