Skip to content

Commit a6c63e5

Browse files
ciampomirka
authored andcommitted
Tests: Lint JavaScript Vitest mock imports (WordPress#83783)
* Tests: Lint JavaScript Vitest mock imports * Tests: Remove optional Vitest rule audit --- Co-authored-by: ciampo <mciampini@git.wordpress.org> Co-authored-by: mirka <0mirka00@git.wordpress.org>
1 parent c652754 commit a6c63e5

43 files changed

Lines changed: 178 additions & 96 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎packages/block-library/src/navigation/test/use-navigation-menu.jsdom.test.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { createRegistry, useSelect } from '@wordpress/data';
33
import { store as coreStore } from '@wordpress/core-data';
44
import useNavigationMenu from '../use-navigation-menu';
55

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

88
const BASE_ENTITY = {
99
kind: 'postType',

‎packages/block-library/src/playlist-track/test/edit.jsdom.test.jsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { useUploadMediaFromBlobURL } from '../../utils/hooks';
77

88
let mockMediaReplaceFlowProps;
99

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

@@ -44,11 +44,11 @@ vi.mock( import( '@wordpress/data' ), async ( importOriginal ) => {
4444
} );
4545
} );
4646

47-
vi.mock( '@wordpress/notices', () => ( {
47+
vi.mock( import( '@wordpress/notices' ), () => ( {
4848
store: 'core/notices',
4949
} ) );
5050

51-
vi.mock( '../../utils/hooks', () => ( {
51+
vi.mock( import( '../../utils/hooks' ), () => ( {
5252
useUploadMediaFromBlobURL: vi.fn(),
5353
} ) );
5454

‎packages/block-library/src/playlist/test/edit-component.jsdom.test.jsx‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ let mediaReplaceFlowProps;
99
// test can look at what ended up in the tracklist.
1010
let mockTracks = [];
1111

12-
vi.mock( '@wordpress/block-editor', () => ( {
12+
vi.mock( import( '@wordpress/block-editor' ), () => ( {
1313
store: {},
1414
BlockControls: ( { children } ) => <div>{ children }</div>,
1515
BlockIcon: () => <span />,
@@ -52,53 +52,53 @@ vi.mock( '@wordpress/block-editor', () => ( {
5252
} ),
5353
} ) );
5454

55-
vi.mock( '@wordpress/blocks', () => ( {
55+
vi.mock( import( '@wordpress/blocks' ), () => ( {
5656
createBlock: vi.fn( ( name, attributes ) => ( {
5757
name,
5858
attributes,
5959
clientId: 'new-track',
6060
} ) ),
6161
} ) );
6262

63-
vi.mock( '@wordpress/blob', () => ( {
63+
vi.mock( import( '@wordpress/blob' ), () => ( {
6464
createBlobURL: vi.fn( () => 'blob:track' ),
6565
} ) );
6666

67-
vi.mock( '@wordpress/components', () => ( {
67+
vi.mock( import( '@wordpress/components' ), () => ( {
6868
Disabled: ( { children } ) => <div>{ children }</div>,
6969
SelectControl: () => <div />,
7070
ToggleControl: () => <div />,
7171
__experimentalToolsPanel: ( { children } ) => <div>{ children }</div>,
7272
__experimentalToolsPanelItem: ( { children } ) => <div>{ children }</div>,
7373
} ) );
7474

75-
vi.mock( '@wordpress/data', () => ( {
75+
vi.mock( import( '@wordpress/data' ), () => ( {
7676
useDispatch: vi.fn(),
7777
useSelect: vi.fn(),
7878
} ) );
7979

80-
vi.mock( '@wordpress/i18n', () => ( {
80+
vi.mock( import( '@wordpress/i18n' ), () => ( {
8181
__: ( text ) => text,
8282
_x: ( text ) => text,
8383
} ) );
8484

85-
vi.mock( '@wordpress/icons', () => ( {
85+
vi.mock( import( '@wordpress/icons' ), () => ( {
8686
playlist: 'playlist',
8787
} ) );
8888

89-
vi.mock( '@wordpress/notices', () => ( {
89+
vi.mock( import( '@wordpress/notices' ), () => ( {
9090
store: {},
9191
} ) );
9292

93-
vi.mock( '../../utils/caption', () => ( {
93+
vi.mock( import( '../../utils/caption' ), () => ( {
9494
Caption: () => <figcaption />,
9595
} ) );
9696

97-
vi.mock( '../../utils/hooks', () => ( {
97+
vi.mock( import( '../../utils/hooks' ), () => ( {
9898
useToolsPanelDropdownMenuProps: () => ( {} ),
9999
} ) );
100100

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

‎packages/blocks/src/api/raw-handling/test/image-corrector.jsdom.test.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { createBlobURL } from '@wordpress/blob';
33
import imageCorrector from '../image-corrector';
44
import { deepFilterHTML } from '../utils';
55

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

‎packages/core-data/src/batch/test/default-processor.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { beforeEach, describe, expect, it, vi } from 'vitest';
22
import apiFetch from '@wordpress/api-fetch';
33

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

66
describe( 'defaultProcessor', () => {
77
let defaultProcessor;

‎packages/core-data/src/components/entities-saved-states/test/use-is-dirty.jsdom.test.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { act, renderHook } from '@testing-library/react';
33
import { useSelect } from '@wordpress/data';
44
import { useIsDirty } from '../hooks/use-is-dirty';
55

6-
vi.mock( '@wordpress/data', () => {
6+
vi.mock( import( '@wordpress/data' ), () => {
77
return {
88
useSelect: vi.fn(),
99
};

‎packages/core-data/src/fetch/test/__experimental-fetch-link-suggestions.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
tokenize,
66
} from '../__experimental-fetch-link-suggestions';
77

8-
vi.mock( '@wordpress/api-fetch', () => ( {
8+
vi.mock( import( '@wordpress/api-fetch' ), () => ( {
99
default: vi.fn( ( { path } ) => {
1010
switch ( path ) {
1111
case '/wp/v2/search?search=&per_page=20&type=post':

‎packages/core-data/src/fetch/test/__experimental-fetch-url-data.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { afterEach, describe, expect, it, vi } from 'vitest';
22
import apiFetch from '@wordpress/api-fetch';
33
import fetchUrlData from '../__experimental-fetch-url-data';
44

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

77
describe( 'fetchUrlData', () => {
88
afterEach( () => {

‎packages/core-data/src/footnotes/test/index.jsdom.test.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { updateFootnotesFromMeta } from '../';
44

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

99
describe( 'updateFootnotesFromMeta', () => {
1010
const blocks = [];

‎packages/core-data/src/hooks/test/use-entity-record.jsdom.test.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { createElement } from '@wordpress/element';
66
import { store as coreDataStore } from '../../index';
77
import useEntityRecord from '../use-entity-record';
88

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

1111
describe( 'useEntityRecord', () => {
1212
let registry;

0 commit comments

Comments
 (0)