File size: 943 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
/**
* @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 );
} );
} );
|