Skip to content

Commit f00a7e6

Browse files
Fix puzzles header tests
1 parent 1c10085 commit f00a7e6

3 files changed

Lines changed: 14 additions & 12 deletions

File tree

dotcom-rendering/src/components/PuzzlesDirectory.test.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,9 @@ import type {
66
PuzzleItem,
77
PuzzlesLayoutType,
88
} from '../types/puzzlesPage';
9-
import { getPuzzleUrl, PuzzlesDirectory } from './PuzzlesDirectory';
109
import { Island } from './Island';
10+
import { getPuzzleUrl, PuzzlesDirectory } from './PuzzlesDirectory';
1111

12-
jest.mock('./AdSlot.web', () => ({
13-
AdSlot: ({ index }: { index: number }) => (
14-
<div data-testid={`ad-${index}`} />
15-
),
16-
}));
1712
jest.mock('./Island', () => ({
1813
Island: jest.fn(({ children }: { children: ReactNode }) => children),
1914
}));
@@ -394,8 +389,12 @@ describe('PuzzlesDirectory', () => {
394389
expect(document.querySelector('img')).not.toBeInTheDocument();
395390
expect(document.querySelector('.js-ad-slot')).not.toBeInTheDocument();
396391
rerender(<PuzzlesDirectory layout={layout} renderAds={true} />);
397-
// Desktop and mobile placements share the configured slot index.
398-
expect(screen.getAllByTestId('ad-2')).toHaveLength(2);
392+
expect(
393+
document.getElementById('dfp-ad--fronts-banner-2'),
394+
).toHaveAttribute('data-name', 'fronts-banner-2');
395+
expect(
396+
document.getElementById('dfp-ad--inline2--mobile'),
397+
).toHaveAttribute('data-name', 'inline2');
399398
});
400399

401400
it('renders the archive dropdown and closes it with Escape or an outside click', async () => {

dotcom-rendering/src/layouts/PuzzlesLayout.test.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ describe('PuzzlesLayout', () => {
3636
it('renders one branded page title without category filters', () => {
3737
render(<PuzzlesLayout NAV={nav} puzzlesPage={page() as never} />);
3838
expect(
39-
screen.getByRole('heading', { level: 1, name: 'Puzzles & Games' }),
39+
screen.getByRole('heading', {
40+
level: 1,
41+
name: 'Puzzles and Games',
42+
}),
4043
).toBeInTheDocument();
4144
expect(screen.getAllByRole('heading', { level: 1 })).toHaveLength(1);
4245
expect(
@@ -66,7 +69,7 @@ describe('PuzzlesLayout', () => {
6669
const header = screen
6770
.getByRole('heading', {
6871
level: 1,
69-
name: 'Puzzles & Games',
72+
name: 'Puzzles and Games',
7073
})
7174
.closest('header')!;
7275
expect(header).toHaveStyle({ height: '230px' });
@@ -78,7 +81,7 @@ describe('PuzzlesLayout', () => {
7881
[1300, 'header-wide-1440px', 1440],
7982
[1140, 'header-leftcol-1280px', 1280],
8083
[980, 'header-desktop-1024px', 1024],
81-
[768, 'header-tablet-979px', 979],
84+
[740, 'header-tablet-768px', 768],
8285
[660, 'header-mobile-phablet-669px', 669],
8386
[480, 'header-mobile-landscape-480px', 480],
8487
[375, 'header-mobile-medium-393px', 393],

dotcom-rendering/src/layouts/PuzzlesLayout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export const PuzzlesLayout = ({
146146
/>
147147
))}
148148
<img
149-
alt=""
149+
alt="An owl carrying a crossword grid beside an octopus reading a puzzle"
150150
css={brandImageStyles}
151151
src={headerArtwork('header-mobile-360px')}
152152
/>

0 commit comments

Comments
 (0)