diff --git a/src/components/Content/Content.spec.tsx b/src/components/Content/Content.spec.tsx new file mode 100644 index 0000000000000000000000000000000000000000..33f8405641d3a810e3aeba704fb74c7eee72e220 --- /dev/null +++ b/src/components/Content/Content.spec.tsx @@ -0,0 +1,39 @@ +import { render, screen, waitFor } from '@testing-library/react' +import React from 'react' +import { Provider } from 'react-redux' +import { + createMockEcolyoStore, + mockChallengeState, + mockGlobalState, +} from 'tests/__mocks__/store' +import Content from './Content' + +window.scrollTo = jest.fn() + +const store = createMockEcolyoStore() +describe('Content component', () => { + it('should match snapshot', async () => { + const { container } = render( + <Provider store={store}> + <Content>children</Content> + </Provider> + ) + await waitFor(() => null, { container }) + expect(container).toMatchSnapshot() + }) + + it('should be rendered with feedback modal opened', async () => { + const store = createMockEcolyoStore({ + global: mockGlobalState, + challenge: mockChallengeState, + modal: { isFeedbacksOpen: true }, + }) + const { container } = render( + <Provider store={store}> + <Content>children</Content> + </Provider> + ) + await waitFor(() => null, { container }) + expect(screen.getByRole('dialog')).toBeInTheDocument() + }) +}) diff --git a/src/components/Content/__snapshots__/Content.spec.tsx.snap b/src/components/Content/__snapshots__/Content.spec.tsx.snap new file mode 100644 index 0000000000000000000000000000000000000000..9fc72e1b3ca438b10ddb746aec2a30352432ed49 --- /dev/null +++ b/src/components/Content/__snapshots__/Content.spec.tsx.snap @@ -0,0 +1,12 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Content component should match snapshot 1`] = ` +<div> + <div + class="content-view" + style="margin-top: 0px; padding-bottom: 0px; min-height: calc(100vh - 0px - 48px - 56px - env(safe-area-inset-top) - env(safe-area-inset-bottom) - env(safe-area-inset-bottom));" + > + children + </div> +</div> +`;