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