|
| 1 | +import React from 'react'; |
| 2 | +import { render, screen } from '@testing-library/react'; |
| 3 | +import { OnboardingSignupHero } from './OnboardingSignupHero'; |
| 4 | + |
| 5 | +jest.mock('../../../contexts/SettingsContext', () => ({ |
| 6 | + ThemeMode: { Dark: 'dark' }, |
| 7 | + useSettingsContext: () => ({ applyThemeMode: jest.fn() }), |
| 8 | +})); |
| 9 | + |
| 10 | +jest.mock('../../../components/Logo', () => ({ |
| 11 | + __esModule: true, |
| 12 | + default: () => <div data-testid="logo" />, |
| 13 | + LogoPosition: { Relative: 'relative' }, |
| 14 | +})); |
| 15 | + |
| 16 | +jest.mock('../../../components/footer/FooterLinks', () => ({ |
| 17 | + FooterLinks: () => <div data-testid="footer" />, |
| 18 | +})); |
| 19 | + |
| 20 | +jest.mock('../../../components/auth/SignupDisclaimer', () => ({ |
| 21 | + __esModule: true, |
| 22 | + default: () => <div data-testid="disclaimer" />, |
| 23 | +})); |
| 24 | + |
| 25 | +// Isolate the shell from the (gql/context-heavy) background blocks. |
| 26 | +jest.mock('./signupHero/HeroBackgroundLayer', () => ({ |
| 27 | + HeroBackgroundLayer: ({ |
| 28 | + background, |
| 29 | + imageMode, |
| 30 | + }: { |
| 31 | + background: string; |
| 32 | + imageMode: string; |
| 33 | + }) => ( |
| 34 | + <div |
| 35 | + data-testid="bg-layer" |
| 36 | + data-background={background} |
| 37 | + data-image-mode={imageMode} |
| 38 | + /> |
| 39 | + ), |
| 40 | +})); |
| 41 | + |
| 42 | +const renderHero = ( |
| 43 | + props: Partial<React.ComponentProps<typeof OnboardingSignupHero>> = {}, |
| 44 | +) => |
| 45 | + render( |
| 46 | + <OnboardingSignupHero background="desk" {...props}> |
| 47 | + <div data-testid="auth-form" /> |
| 48 | + </OnboardingSignupHero>, |
| 49 | + ); |
| 50 | + |
| 51 | +describe('OnboardingSignupHero', () => { |
| 52 | + it('passes background and image mode to the background layer', () => { |
| 53 | + renderHero({ background: 'desk', imageMode: 'colors' }); |
| 54 | + const layer = screen.getByTestId('bg-layer'); |
| 55 | + expect(layer).toHaveAttribute('data-background', 'desk'); |
| 56 | + expect(layer).toHaveAttribute('data-image-mode', 'colors'); |
| 57 | + }); |
| 58 | + |
| 59 | + it('renders aurora orbs by default', () => { |
| 60 | + renderHero(); |
| 61 | + expect(screen.getByTestId('hero-orbs')).toBeInTheDocument(); |
| 62 | + }); |
| 63 | + |
| 64 | + it('omits aurora orbs when showOrbs is false', () => { |
| 65 | + renderHero({ showOrbs: false }); |
| 66 | + expect(screen.queryByTestId('hero-orbs')).not.toBeInTheDocument(); |
| 67 | + }); |
| 68 | + |
| 69 | + it('renders the halo and vignette as part of the desk background', () => { |
| 70 | + renderHero({ background: 'desk' }); |
| 71 | + expect(screen.getByTestId('hero-halo')).toBeInTheDocument(); |
| 72 | + }); |
| 73 | + |
| 74 | + it('omits the halo for the cards background', () => { |
| 75 | + renderHero({ background: 'cards' }); |
| 76 | + expect(screen.queryByTestId('hero-halo')).not.toBeInTheDocument(); |
| 77 | + }); |
| 78 | + |
| 79 | + it('renders the form and headline', () => { |
| 80 | + renderHero({ headline: 'Hello devs' }); |
| 81 | + expect(screen.getByTestId('auth-form')).toBeInTheDocument(); |
| 82 | + expect(screen.getByText('Hello devs')).toBeInTheDocument(); |
| 83 | + }); |
| 84 | +}); |
0 commit comments