react-code-dataset / wp-calypso /client /sites /settings /administration /tools /test /export-notice.jsx
react-code-dataset / wp-calypso /client /sites /settings /administration /tools /test /export-notice.jsx
Download wp-calypso/client/sites/settings/administration/tools/test/export-notice.jsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.42 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/sites/settings/administration/tools/test/export-notice.jsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/sites/settings/administration/tools/test/export-notice.jsx
-
curl -L -o export-notice.jsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/sites/settings/administration/tools/test/export-notice.jsx
1.42 kB
| /** | |
| * @jest-environment jsdom | |
| */ | |
| import { render, screen, fireEvent } from '@testing-library/react'; | |
| import ExportNotice from '../export-notice'; | |
| jest.mock( 'i18n-calypso', () => ( { | |
| ...jest.requireActual( 'i18n-calypso' ), | |
| translate: jest.fn( ( key ) => key ), | |
| } ) ); | |
| describe( 'ExportNotice', () => { | |
| const defaultProps = { | |
| siteId: 123, | |
| siteSlug: 'example-site', | |
| warningText: 'This is a warning.', | |
| }; | |
| it( 'renders the warning notice with the correct text', () => { | |
| render( <ExportNotice { ...defaultProps } /> ); | |
| expect( screen.getByText( 'This is a warning.' ) ).toBeInTheDocument(); | |
| } ); | |
| it( 'has the correct href for the export link', () => { | |
| render( <ExportNotice { ...defaultProps } /> ); | |
| const link = screen.getByRole( 'link', { name: 'Export content' } ); | |
| expect( link ).toHaveAttribute( 'href', '/export/example-site' ); | |
| } ); | |
| it( 'prevents navigation when siteId is missing', () => { | |
| render( <ExportNotice { ...defaultProps } siteId={ 0 } /> ); | |
| const link = screen.getByRole( 'link', { name: 'Export content' } ); | |
| const clickEvent = fireEvent.click( link ); | |
| expect( clickEvent ).toBe( false ); | |
| } ); | |
| it( 'allows navigation when siteId is provided', () => { | |
| render( <ExportNotice { ...defaultProps } /> ); | |
| const link = screen.getByRole( 'link', { name: 'Export content' } ); | |
| const clickEvent = fireEvent.click( link ); | |
| expect( clickEvent ).toBe( true ); | |
| } ); | |
| } ); | |