Skip to content

Commit f22a5f4

Browse files
committed
refactor: Rename functions for consistency
1 parent 0522042 commit f22a5f4

File tree

4 files changed

+18
-19
lines changed

4 files changed

+18
-19
lines changed

src/utils/api-fetch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { getGBKit } from './bridge';
1818
*
1919
* @return {void}
2020
*/
21-
export function initializeApiFetch() {
21+
export function configureApiFetch() {
2222
const { siteApiRoot = '' } = getGBKit();
2323

2424
apiFetch.use( apiFetch.createRootURLMiddleware( siteApiRoot ) );

src/utils/api-fetch.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import apiFetch from '@wordpress/api-fetch';
1919
/**
2020
* Internal dependencies
2121
*/
22-
import { initializeApiFetch } from './api-fetch';
22+
import { configureApiFetch } from './api-fetch';
2323
import * as bridge from './bridge';
2424

2525
vi.mock( './bridge' );
@@ -34,7 +34,7 @@ describe( 'api-fetch credentials handling', () => {
3434
} );
3535

3636
// Initialize middleware once - it will persist across all tests
37-
initializeApiFetch();
37+
configureApiFetch();
3838
} );
3939

4040
beforeEach( () => {

src/utils/editor-environment.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ export async function setUpEditorEnvironment() {
2323
setBodyClasses( window );
2424
await awaitGBKitGlobal();
2525
await configureLocale();
26-
await loadWordPressGlobals();
27-
await initializeApiFetchWrapper();
26+
await initializeWordPressGlobals();
27+
await configureApiFetch();
2828
initializeVideoPressAjaxBridge();
2929
const pluginLoadResult = await loadPluginsIfEnabled();
3030
await initializeEditor( pluginLoadResult );
@@ -65,23 +65,22 @@ function setBodyClasses( global ) {
6565
*
6666
* @return {Promise} Promise that resolves when WordPress globals are initialized
6767
*/
68-
async function loadWordPressGlobals() {
69-
const { initializeWordPressGlobals } = await import(
70-
'./wordpress-globals'
71-
);
72-
initializeWordPressGlobals();
68+
async function initializeWordPressGlobals() {
69+
const { initializeWordPressGlobals: _initializeWordPressGlobals } =
70+
await import( './wordpress-globals' );
71+
_initializeWordPressGlobals();
7372
}
7473

7574
/**
7675
* Configure `api-fetch` middleware and settings. Lazy-loaded to ensure
7776
* WordPress globals are available before importing `api-fetch` and
7877
* referencing `window.wp.apiFetch`.
7978
*/
80-
async function initializeApiFetchWrapper() {
81-
const { initializeApiFetch: _initializeApiFetch } = await import(
79+
async function configureApiFetch() {
80+
const { configureApiFetch: _configureApiFetch } = await import(
8281
'./api-fetch'
8382
);
84-
_initializeApiFetch();
83+
_configureApiFetch();
8584
}
8685

8786
/**

src/utils/editor-environment.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { error } from './logger.js';
1414
import { initializeVideoPressAjaxBridge } from './videopress-bridge.js';
1515
import { initializeWordPressGlobals } from './wordpress-globals.js';
1616
import { configureLocale } from './localization.js';
17-
import { initializeApiFetch } from './api-fetch.js';
17+
import { configureApiFetch } from './api-fetch.js';
1818
import { initializeEditor } from './editor.jsx';
1919

2020
vi.mock( './bridge.js' );
@@ -39,7 +39,7 @@ vi.mock( './localization.js', () => ( {
3939
} ) );
4040

4141
vi.mock( './api-fetch.js', () => ( {
42-
initializeApiFetch: vi.fn(),
42+
configureApiFetch: vi.fn(),
4343
} ) );
4444

4545
vi.mock( './editor.jsx', () => ( {
@@ -54,7 +54,7 @@ describe( 'setUpEditorEnvironment', () => {
5454
getGBKit.mockReturnValue( { plugins: false } );
5555
configureLocale.mockResolvedValue( undefined );
5656
initializeWordPressGlobals.mockImplementation( () => {} );
57-
initializeApiFetch.mockImplementation( () => {} );
57+
configureApiFetch.mockImplementation( () => {} );
5858
initializeVideoPressAjaxBridge.mockImplementation( () => {} );
5959
initializeEditor.mockImplementation( () => {} );
6060
EditorLoadError.mockReturnValue( '<div>Error</div>' );
@@ -80,8 +80,8 @@ describe( 'setUpEditorEnvironment', () => {
8080
callOrder.push( 'loadRemainingGlobals' );
8181
} );
8282

83-
initializeApiFetch.mockImplementation( () => {
84-
callOrder.push( 'initializeApiFetch' );
83+
configureApiFetch.mockImplementation( () => {
84+
callOrder.push( 'configureApiFetch' );
8585
} );
8686

8787
initializeVideoPressAjaxBridge.mockImplementation( () => {
@@ -98,7 +98,7 @@ describe( 'setUpEditorEnvironment', () => {
9898
'awaitGBKitGlobal',
9999
'configureLocale',
100100
'loadRemainingGlobals',
101-
'initializeApiFetch',
101+
'configureApiFetch',
102102
'initializeVideoPress',
103103
'initializeEditor',
104104
] );

0 commit comments

Comments
 (0)