Skip to content

Commit 7fad062

Browse files
committed
update opts
1 parent b3d5d33 commit 7fad062

2 files changed

Lines changed: 52 additions & 9 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import React from 'react';
2+
import { render, screen } from '@testing-library/react';
3+
import { HeroBackgroundLayer } from './HeroBackgroundLayer';
4+
5+
jest.mock('./CardsBackground', () => ({
6+
CardsBackground: ({ splitMode }: { splitMode?: boolean }) => (
7+
<div data-testid="cards-bg" data-split={String(!!splitMode)} />
8+
),
9+
}));
10+
11+
jest.mock('./DeskBackground', () => ({
12+
DeskBackground: () => <div data-testid="desk-bg" />,
13+
}));
14+
15+
describe('HeroBackgroundLayer', () => {
16+
it('renders the cards mosaic for the cards background regardless of image mode', () => {
17+
render(<HeroBackgroundLayer background="cards" imageMode="colors" />);
18+
expect(screen.getByTestId('cards-bg')).toHaveAttribute(
19+
'data-split',
20+
'false',
21+
);
22+
expect(screen.queryByTestId('desk-bg')).not.toBeInTheDocument();
23+
});
24+
25+
it('renders the split cards mosaic for the split background', () => {
26+
render(<HeroBackgroundLayer background="split" imageMode="image" />);
27+
expect(screen.getByTestId('cards-bg')).toHaveAttribute(
28+
'data-split',
29+
'true',
30+
);
31+
});
32+
33+
it('renders the desk photo when image mode is image', () => {
34+
render(<HeroBackgroundLayer background="desk" imageMode="image" />);
35+
expect(screen.getByTestId('desk-bg')).toBeInTheDocument();
36+
expect(screen.queryByTestId('cards-bg')).not.toBeInTheDocument();
37+
});
38+
39+
it('omits the desk photo when image mode is colors', () => {
40+
render(<HeroBackgroundLayer background="desk" imageMode="colors" />);
41+
expect(screen.queryByTestId('desk-bg')).not.toBeInTheDocument();
42+
expect(screen.queryByTestId('cards-bg')).not.toBeInTheDocument();
43+
});
44+
});

packages/shared/src/features/onboarding/components/signupHero/HeroBackgroundLayer.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ import { DeskBackground } from './DeskBackground';
99

1010
// =============================================================
1111
// Background layer — renders the selected background's artwork.
12-
// In 'colors' image mode the artwork is omitted, leaving just the
13-
// gradient backdrop.
12+
//
13+
// The cards and split backgrounds are always the live feed-cards
14+
// mosaic. `imageMode` only applies to the desk background (the only
15+
// one with an actual photo): 'colors' omits the photo, leaving just
16+
// the gradient backdrop.
1417
// =============================================================
1518

1619
type HeroBackgroundLayerProps = {
@@ -22,13 +25,9 @@ export const HeroBackgroundLayer = ({
2225
background,
2326
imageMode,
2427
}: HeroBackgroundLayerProps): ReactElement | null => {
25-
if (imageMode === 'colors') {
26-
return null;
28+
if (background === 'desk') {
29+
return imageMode === 'colors' ? null : <DeskBackground />;
2730
}
2831

29-
return background === 'desk' ? (
30-
<DeskBackground />
31-
) : (
32-
<CardsBackground splitMode={background === 'split'} />
33-
);
32+
return <CardsBackground splitMode={background === 'split'} />;
3433
};

0 commit comments

Comments
 (0)