Skip to content

Commit 88f3c77

Browse files
committed
test: add test for SplashPresentation.shouldShowCommunityRows
1 parent 4c3be40 commit 88f3c77

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import React from 'react';
2+
3+
import {SplashPresentation} from '../../../src/views/splash/presentation.jsx';
4+
import {renderWithIntl} from '../../helpers/react-testing-library-wrapper.jsx';
5+
6+
/**
7+
* Values for the required props of the `SplashPresentation` component corresponding to a normal/common state.
8+
*/
9+
const basicProps = {
10+
isAdmin: false,
11+
isEducator: false,
12+
onCloseAdminPanel: () => {},
13+
onCloseDonateBanner: () => {},
14+
onDismiss: () => {},
15+
onOpenAdminPanel: () => {},
16+
onRefreshHomepageCache: () => {},
17+
refreshCacheStatus: {},
18+
sessionStatus: {},
19+
shouldShowDonateBanner: false,
20+
shouldShowEmailConfirmation: false,
21+
shouldShowFeaturesBanner: false,
22+
shouldShowHOCMiddleBanner: false,
23+
shouldShowHOCTopBanner: false,
24+
shouldShowIntro: false,
25+
shouldShowWelcome: false,
26+
user: {}
27+
};
28+
29+
// Lazy mock for react-slick so we don't have to mock or polyfill matchMedia
30+
// See https://github.com/akiran/react-slick/issues/742#issuecomment-1934298590
31+
jest.mock('react-slick', () => ({
32+
__esModule: true,
33+
default: ({children}) => <div data-testid="slick_mock">{children}</div>
34+
}));
35+
36+
describe('SplashPresentation', () => {
37+
test('renders title and subtitle', () => {
38+
const props = Object.assign({}, basicProps, {
39+
shouldShowCommunityRows: false
40+
});
41+
const componentWith = renderWithIntl(
42+
<SplashPresentation
43+
{...props}
44+
shouldShowCommunityRows
45+
/>,
46+
'SplashPresentation'
47+
);
48+
const componentWithout = renderWithIntl(
49+
<SplashPresentation
50+
{...props}
51+
shouldShowCommunityRows={false}
52+
/>,
53+
'SplashPresentation'
54+
);
55+
56+
expect(componentWith.getByText('What the Community is Remixing')).toBeInTheDocument();
57+
expect(componentWithout.getByText('What the Community is Remixing')).not.toBeInTheDocument();
58+
});
59+
});

0 commit comments

Comments
 (0)