From 9d72873672e196fcac505877170278eca7f30def Mon Sep 17 00:00:00 2001 From: Jack Stevens Date: Fri, 10 May 2024 16:52:39 +0100 Subject: [PATCH] chore: convert data-controls test to typescript --- packages/data-controls/src/test/{index.js => index.ts} | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) rename packages/data-controls/src/test/{index.js => index.ts} (69%) diff --git a/packages/data-controls/src/test/index.js b/packages/data-controls/src/test/index.ts similarity index 69% rename from packages/data-controls/src/test/index.js rename to packages/data-controls/src/test/index.ts index a9fedde4e289c..df8a0423957af 100644 --- a/packages/data-controls/src/test/index.js +++ b/packages/data-controls/src/test/index.ts @@ -1,6 +1,7 @@ /** * WordPress dependencies */ +import type { APIFetchOptions } from '@wordpress/api-fetch'; import triggerFetch from '@wordpress/api-fetch'; jest.mock( '@wordpress/api-fetch' ); @@ -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' ); } ); } );