Download wp-calypso/client/jetpack-connect/test/jetpack-connect-notices.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.61 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/jetpack-connect/test/jetpack-connect-notices.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/jetpack-connect/test/jetpack-connect-notices.js
-
curl -L -o jetpack-connect-notices.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/jetpack-connect/test/jetpack-connect-notices.js
1.61 kB
| /** | |
| * @jest-environment jsdom | |
| */ | |
| import { render } from '@testing-library/react'; | |
| import { JetpackConnectNotices } from '../jetpack-connect-notices'; | |
| const terminalErrorNoticeType = 'siteBlocked'; | |
| const nonTerminalErrorNoticeType = 'retryAuth'; | |
| const requiredProps = { translate: ( string ) => string }; | |
| describe( 'JetpackConnectNotices', () => { | |
| test( 'Should render notice', () => { | |
| const { container } = render( | |
| <JetpackConnectNotices { ...requiredProps } noticeType={ terminalErrorNoticeType } /> | |
| ); | |
| expect( container ).toMatchSnapshot(); | |
| } ); | |
| test( 'Should not render terminal notice if callback supplied', () => { | |
| const onTerminalError = jest.fn(); | |
| const { container } = render( | |
| <JetpackConnectNotices | |
| { ...requiredProps } | |
| noticeType={ terminalErrorNoticeType } | |
| onTerminalError={ onTerminalError } | |
| /> | |
| ); | |
| expect( container ).toBeEmptyDOMElement(); | |
| } ); | |
| test( 'Should call callback on terminal error', () => { | |
| const onTerminalError = jest.fn(); | |
| render( | |
| <JetpackConnectNotices | |
| { ...requiredProps } | |
| noticeType={ terminalErrorNoticeType } | |
| onTerminalError={ onTerminalError } | |
| /> | |
| ); | |
| expect( onTerminalError ).toHaveBeenCalledTimes( 1 ); | |
| } ); | |
| test( 'Should render non-terminal notice if callback supplied', () => { | |
| const onTerminalError = jest.fn(); | |
| const { container } = render( | |
| <JetpackConnectNotices | |
| { ...requiredProps } | |
| noticeType={ nonTerminalErrorNoticeType } | |
| onTerminalError={ onTerminalError } | |
| /> | |
| ); | |
| expect( onTerminalError ).not.toHaveBeenCalled(); | |
| expect( container ).toMatchSnapshot(); | |
| } ); | |
| } ); | |