Skip to content

Commit

Permalink
chore: convert data-controls test to typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
jpstevens committed May 10, 2024
1 parent 2373c53 commit 9d72873
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* WordPress dependencies
*/
import type { APIFetchOptions } from '@wordpress/api-fetch';
import triggerFetch from '@wordpress/api-fetch';

jest.mock( '@wordpress/api-fetch' );
Expand All @@ -13,14 +14,14 @@ import { controls } from '../index';
describe( 'controls', () => {
describe( 'API_FETCH', () => {
afterEach( () => {
triggerFetch.mockClear();
( triggerFetch as unknown as jest.Mock ).mockClear();
} );
it( 'invokes the triggerFetch function', () => {
controls.API_FETCH( { request: '' } );
controls.API_FETCH( { request: '' as APIFetchOptions } );
expect( triggerFetch ).toHaveBeenCalledTimes( 1 );
} );
it( 'invokes the triggerFetch function with the passed in request', () => {
controls.API_FETCH( { request: 'foo' } );
controls.API_FETCH( { request: 'foo' as APIFetchOptions } );
expect( triggerFetch ).toHaveBeenCalledWith( 'foo' );
} );
} );
Expand Down

0 comments on commit 9d72873

Please sign in to comment.