react-code-dataset / wp-calypso /client /landing /stepper /hooks /test /use-send-email-verification.jsx
react-code-dataset / wp-calypso /client /landing /stepper /hooks /test /use-send-email-verification.jsx
Download wp-calypso/client/landing/stepper/hooks/test/use-send-email-verification.jsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 943 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/landing/stepper/hooks/test/use-send-email-verification.jsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/landing/stepper/hooks/test/use-send-email-verification.jsx
-
curl -L -o use-send-email-verification.jsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/landing/stepper/hooks/test/use-send-email-verification.jsx
943 Bytes
| /** | |
| * @jest-environment jsdom | |
| */ | |
| import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | |
| import { renderHook } from '@testing-library/react'; | |
| import nock from 'nock'; | |
| import { useSendEmailVerification } from '../use-send-email-verification'; | |
| describe( 'use-send-email-verification hook', () => { | |
| test( 'returns success from the api', async () => { | |
| const queryClient = new QueryClient(); | |
| const wrapper = ( { children } ) => ( | |
| <QueryClientProvider client={ queryClient }>{ children }</QueryClientProvider> | |
| ); | |
| const expected = { | |
| success: true, | |
| }; | |
| nock( 'https://public-api.wordpress.com' ) | |
| .post( '/rest/v1.1/me/send-verification-email' ) | |
| .reply( 200, expected ); | |
| const { result } = renderHook( () => useSendEmailVerification(), { | |
| wrapper, | |
| } ); | |
| const sendEmailVerification = result.current; | |
| const data = await sendEmailVerification(); | |
| expect( data ).toEqual( expected ); | |
| } ); | |
| } ); | |