Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createRegistry, useSelect } from '@wordpress/data';
import { store as coreStore } from '@wordpress/core-data';
import useNavigationMenu from '../use-navigation-menu';

vi.mock( '@wordpress/api-fetch' );
vi.mock( import( '@wordpress/api-fetch' ) );

const BASE_ENTITY = {
kind: 'postType',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useUploadMediaFromBlobURL } from '../../utils/hooks';

let mockMediaReplaceFlowProps;

vi.mock( '@wordpress/block-editor', async () => {
vi.mock( import( '@wordpress/block-editor' ), async () => {
const { default: PlainText } =
await import( '../../../../block-editor/src/components/plain-text' );

Expand Down Expand Up @@ -44,11 +44,11 @@ vi.mock( import( '@wordpress/data' ), async ( importOriginal ) => {
} );
} );

vi.mock( '@wordpress/notices', () => ( {
vi.mock( import( '@wordpress/notices' ), () => ( {
store: 'core/notices',
} ) );

vi.mock( '../../utils/hooks', () => ( {
vi.mock( import( '../../utils/hooks' ), () => ( {
useUploadMediaFromBlobURL: vi.fn(),
} ) );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let mediaReplaceFlowProps;
// test can look at what ended up in the tracklist.
let mockTracks = [];

vi.mock( '@wordpress/block-editor', () => ( {
vi.mock( import( '@wordpress/block-editor' ), () => ( {
store: {},
BlockControls: ( { children } ) => <div>{ children }</div>,
BlockIcon: () => <span />,
Expand Down Expand Up @@ -52,53 +52,53 @@ vi.mock( '@wordpress/block-editor', () => ( {
} ),
} ) );

vi.mock( '@wordpress/blocks', () => ( {
vi.mock( import( '@wordpress/blocks' ), () => ( {
createBlock: vi.fn( ( name, attributes ) => ( {
name,
attributes,
clientId: 'new-track',
} ) ),
} ) );

vi.mock( '@wordpress/blob', () => ( {
vi.mock( import( '@wordpress/blob' ), () => ( {
createBlobURL: vi.fn( () => 'blob:track' ),
} ) );

vi.mock( '@wordpress/components', () => ( {
vi.mock( import( '@wordpress/components' ), () => ( {
Disabled: ( { children } ) => <div>{ children }</div>,
SelectControl: () => <div />,
ToggleControl: () => <div />,
__experimentalToolsPanel: ( { children } ) => <div>{ children }</div>,
__experimentalToolsPanelItem: ( { children } ) => <div>{ children }</div>,
} ) );

vi.mock( '@wordpress/data', () => ( {
vi.mock( import( '@wordpress/data' ), () => ( {
useDispatch: vi.fn(),
useSelect: vi.fn(),
} ) );

vi.mock( '@wordpress/i18n', () => ( {
vi.mock( import( '@wordpress/i18n' ), () => ( {
__: ( text ) => text,
_x: ( text ) => text,
} ) );

vi.mock( '@wordpress/icons', () => ( {
vi.mock( import( '@wordpress/icons' ), () => ( {
playlist: 'playlist',
} ) );

vi.mock( '@wordpress/notices', () => ( {
vi.mock( import( '@wordpress/notices' ), () => ( {
store: {},
} ) );

vi.mock( '../../utils/caption', () => ( {
vi.mock( import( '../../utils/caption' ), () => ( {
Caption: () => <figcaption />,
} ) );

vi.mock( '../../utils/hooks', () => ( {
vi.mock( import( '../../utils/hooks' ), () => ( {
useToolsPanelDropdownMenuProps: () => ( {} ),
} ) );

vi.mock( '../../utils/waveform-player', () => ( {
vi.mock( import( '../../utils/waveform-player' ), () => ( {
WaveformPlayer: () => <div />,
} ) );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createBlobURL } from '@wordpress/blob';
import imageCorrector from '../image-corrector';
import { deepFilterHTML } from '../utils';

vi.mock( '@wordpress/blob', () => ( {
vi.mock( import( '@wordpress/blob' ), () => ( {
createBlobURL: vi.fn( () => 'blob:local-url' ),
} ) );

Expand Down
2 changes: 1 addition & 1 deletion packages/core-data/src/batch/test/default-processor.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
import apiFetch from '@wordpress/api-fetch';

vi.mock( '@wordpress/api-fetch' );
vi.mock( import( '@wordpress/api-fetch' ) );

describe( 'defaultProcessor', () => {
let defaultProcessor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { act, renderHook } from '@testing-library/react';
import { useSelect } from '@wordpress/data';
import { useIsDirty } from '../hooks/use-is-dirty';

vi.mock( '@wordpress/data', () => {
vi.mock( import( '@wordpress/data' ), () => {
return {
useSelect: vi.fn(),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
tokenize,
} from '../__experimental-fetch-link-suggestions';

vi.mock( '@wordpress/api-fetch', () => ( {
vi.mock( import( '@wordpress/api-fetch' ), () => ( {
default: vi.fn( ( { path } ) => {
switch ( path ) {
case '/wp/v2/search?search=&per_page=20&type=post':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { afterEach, describe, expect, it, vi } from 'vitest';
import apiFetch from '@wordpress/api-fetch';
import fetchUrlData from '../__experimental-fetch-url-data';

vi.mock( '@wordpress/api-fetch' );
vi.mock( import( '@wordpress/api-fetch' ) );

describe( 'fetchUrlData', () => {
afterEach( () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { updateFootnotesFromMeta } from '../';

// The real implementation logs once per distinct message, which would make
// per-case assertions depend on the order the cases run in.
vi.mock( '@wordpress/warning' );
vi.mock( import( '@wordpress/warning' ) );

describe( 'updateFootnotesFromMeta', () => {
const blocks = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { createElement } from '@wordpress/element';
import { store as coreDataStore } from '../../index';
import useEntityRecord from '../use-entity-record';

vi.mock( '@wordpress/api-fetch' );
vi.mock( import( '@wordpress/api-fetch' ) );

describe( 'useEntityRecord', () => {
let registry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import useEntityRecords, {
useEntityRecordsWithPermissions,
} from '../use-entity-records';

vi.mock( '@wordpress/api-fetch' );
vi.mock( import( '@wordpress/api-fetch' ) );

describe( 'useEntityRecords', () => {
let registry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { createElement } from '@wordpress/element';
import { store as coreDataStore } from '../../index';
import useResourcePermissions from '../use-resource-permissions';

vi.mock( '@wordpress/api-fetch' );
vi.mock( import( '@wordpress/api-fetch' ) );

describe( 'useResourcePermissions', () => {
let registry;
Expand Down
4 changes: 2 additions & 2 deletions packages/core-data/src/test/actions.jsdom.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
__experimentalBatch,
} from '../actions';
import { getEntitySyncManager } from '../entity-sync';
vi.mock( '@wordpress/api-fetch' );
vi.mock( import( '@wordpress/api-fetch' ) );

vi.mock( import( '../batch' ), async ( importOriginal ) => {
const { createBatch } = await importOriginal();
Expand All @@ -23,7 +23,7 @@ vi.mock( import( '../batch' ), async ( importOriginal ) => {
};
} );

vi.mock( '../entity-sync', () => ( {
vi.mock( import( '../entity-sync' ), () => ( {
getEntitySyncManager: vi.fn(),
} ) );

Expand Down
2 changes: 1 addition & 1 deletion packages/core-data/src/test/can-user.jsdom.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import triggerFetch from '@wordpress/api-fetch';
import { createRegistry } from '@wordpress/data';
import { store as coreDataStore } from '../index';

vi.mock( '@wordpress/api-fetch' );
vi.mock( import( '@wordpress/api-fetch' ) );

const ALLOW_ALL = {
headers: new Map( [ [ 'allow', 'POST, GET, PUT, DELETE' ] ] ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import deprecated from '@wordpress/deprecated';
import { createRegistry } from '@wordpress/data';
import { store as coreDataStore } from '../index';

vi.mock( '@wordpress/deprecated' );
vi.mock( '@wordpress/api-fetch' );
vi.mock( import( '@wordpress/deprecated' ) );
vi.mock( import( '@wordpress/api-fetch' ) );

/**
* Returns the expected arguments for the deprecated function call.
Expand Down
2 changes: 1 addition & 1 deletion packages/core-data/src/test/entities.jsdom.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
additionalEntityConfigLoaders,
} from '../entities';
import { applyPostChangesToCRDTDoc } from '../utils/crdt';
vi.mock( '@wordpress/api-fetch' );
vi.mock( import( '@wordpress/api-fetch' ) );
vi.mock( import( '../utils/crdt' ), async ( importOriginal ) => ( {
...( await importOriginal() ),
applyPostChangesToCRDTDoc: vi.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { unregisterFormatType } from '@wordpress/rich-text';
import { store as coreDataStore } from '../index';
import useEntityBlockEditor from '../hooks/use-entity-block-editor';

vi.mock( '@wordpress/api-fetch' );
vi.mock( import( '@wordpress/api-fetch' ) );

const postTypeConfig = {
kind: 'postType',
Expand Down
4 changes: 2 additions & 2 deletions packages/core-data/src/test/entity-sync.jsdom.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import { getUndoManager } from '../private-selectors';
import { getEntityRecord, getEntityRecords } from '../resolvers';
import { hasRedo, hasUndo } from '../selectors';

vi.mock( '@wordpress/api-fetch' );
vi.mock( '@wordpress/warning' );
vi.mock( import( '@wordpress/api-fetch' ) );
vi.mock( import( '@wordpress/warning' ) );

/**
* A fake manager that records every interface call.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { editMediaEntity, setCollaborationSupported } from '../private-actions';
import { getEntitySyncManager } from '../entity-sync';
import { unlock } from '../lock-unlock';

vi.mock( '@wordpress/api-fetch' );
vi.mock( import( '@wordpress/api-fetch' ) );
vi.mock( import( '../entity-sync' ), async ( importOriginal ) => ( {
...( await importOriginal() ),
getEntitySyncManager: vi.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { afterEach, describe, expect, it, vi } from 'vitest';
import { getUndoManager } from '../private-selectors';
import { getEntitySyncManager } from '../entity-sync';

vi.mock( '../entity-sync', () => ( {
vi.mock( import( '../entity-sync' ), () => ( {
getEntitySyncManager: vi.fn(),
} ) );

Expand Down
4 changes: 2 additions & 2 deletions packages/core-data/src/test/resolvers.jsdom.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
getCurrentUser,
} from '../resolvers';
import { RECEIVE_INTERMEDIATE_RESULTS } from '../utils';
vi.mock( '@wordpress/api-fetch' );
vi.mock( '../entity-sync', () => ( {
vi.mock( import( '@wordpress/api-fetch' ) );
vi.mock( import( '../entity-sync' ), () => ( {
getEntitySyncManager: vi.fn(),
} ) );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import useEntityBlockEditor from '../hooks/use-entity-block-editor';
import { applyPostChangesToCRDTDoc } from '../utils/crdt';
import { getRootMap } from '../utils/crdt-utils';

vi.mock( '@wordpress/api-fetch' );
vi.mock( import( '@wordpress/api-fetch' ) );

const postTypeConfig = {
kind: 'postType',
Expand Down
2 changes: 1 addition & 1 deletion packages/core-data/src/test/selectors.jsdom.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
} from '../selectors';
import { getEntitySyncManager } from '../entity-sync';

vi.mock( '../entity-sync', () => ( {
vi.mock( import( '../entity-sync' ), () => ( {
getEntitySyncManager: vi.fn(),
} ) );

Expand Down
2 changes: 1 addition & 1 deletion packages/core-data/src/test/store.jsdom.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import triggerFetch from '@wordpress/api-fetch';
import { createRegistry } from '@wordpress/data';
import { store as coreDataStore } from '../index';

vi.mock( '@wordpress/api-fetch' );
vi.mock( import( '@wordpress/api-fetch' ) );

function createTestRegistry() {
const registry = createRegistry();
Expand Down
12 changes: 6 additions & 6 deletions packages/core-data/src/test/sync.jsdom.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const { mockSyncManager, mockCreateSyncManager, mockSaveCRDTDoc } = vi.hoisted(
}
);

vi.mock( '@wordpress/sync', () => ( {
vi.mock( import( '@wordpress/sync' ), () => ( {
privateApis: {
createSyncManager: mockCreateSyncManager,
ConnectionErrorCode: {},
Expand All @@ -32,17 +32,17 @@ vi.mock( '@wordpress/sync', () => ( {
},
} ) );

vi.mock( '../lock-unlock', () => ( {
vi.mock( import( '../lock-unlock' ), () => ( {
unlock: ( privateApis ) => privateApis,
} ) );

// Keep the adapter's module graph small: the entity configs and the CRDT
// utilities pull in the block library, which does not survive module resets.
vi.mock( '../entities', () => ( {
vi.mock( import( '../entities' ), () => ( {
DEFAULT_ENTITY_KEY: 'id',
} ) );

vi.mock( '../utils/crdt', () => ( {
vi.mock( import( '../utils/crdt' ), () => ( {
POST_META_KEY_FOR_CRDT_DOC_PERSISTENCE: '_crdt_document',
// Mirrors `getRawValue` in utils/crdt.ts.
getRawValue: ( value ) => {
Expand All @@ -61,11 +61,11 @@ vi.mock( '../utils/crdt', () => ( {
},
} ) );

vi.mock( '../utils/save-crdt-doc', () => ( {
vi.mock( import( '../utils/save-crdt-doc' ), () => ( {
saveCRDTDoc: mockSaveCRDTDoc,
} ) );

vi.mock( '../utils/crdt-selection', () => ( {
vi.mock( import( '../utils/crdt-selection' ), () => ( {
getSelectionHistory: vi.fn(),
restoreSelection: vi.fn(),
} ) );
Expand Down
4 changes: 2 additions & 2 deletions packages/core-data/src/utils/test/log-entity-deprecation.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import deprecated from '@wordpress/deprecated';
import logEntityDeprecation from '../log-entity-deprecation';

// Mock the deprecatedEntities import
vi.mock( '../../entities', () => ( {
vi.mock( import( '../../entities' ), () => ( {
deprecatedEntities: {
root: {
media: {
Expand All @@ -18,7 +18,7 @@ vi.mock( '../../entities', () => ( {
} ) );

// Mock the deprecated function
vi.mock( '@wordpress/deprecated' );
vi.mock( import( '@wordpress/deprecated' ) );

describe( 'logEntityDeprecation', () => {
beforeEach( () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ vi.mock( import( '@wordpress/blocks' ), async ( importOriginal ) => {
};
} );

vi.mock( '../../../../sync/src/providers', () => ( {
vi.mock( import( '../../../../sync/src/providers' ), () => ( {
getProviderCreators: vi.fn(),
} ) );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ vi.mock( import( '@wordpress/blocks' ), async ( importOriginal ) => {
};
} );

vi.mock( '../../../../sync/src/providers', () => ( {
vi.mock( import( '../../../../sync/src/providers' ), () => ( {
getProviderCreators: vi.fn(),
} ) );

Expand Down
4 changes: 2 additions & 2 deletions packages/core-data/src/utils/test/save-crdt-doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import apiFetch from '@wordpress/api-fetch';
import { getSyncManager } from '../../sync';
import { saveCRDTDoc } from '../save-crdt-doc';

vi.mock( '@wordpress/api-fetch' );
vi.mock( '../../sync', () => ( {
vi.mock( import( '@wordpress/api-fetch' ) );
vi.mock( import( '../../sync' ), () => ( {
getSyncManager: vi.fn(),
} ) );

Expand Down
Loading
Loading