parent
8ce25e6b1b
commit
3dc5f95254
|
@ -9,7 +9,17 @@ import { useSelect, useDispatch } from '@wordpress/data';
|
|||
*/
|
||||
import TransientNotices from '..';
|
||||
|
||||
jest.mock( '@wordpress/data' );
|
||||
jest.mock( '@wordpress/data', () => {
|
||||
// Require the original module to not be mocked...
|
||||
const originalModule = jest.requireActual( '@wordpress/data' );
|
||||
|
||||
return {
|
||||
__esModule: true, // Use it when dealing with esModules
|
||||
...originalModule,
|
||||
useDispatch: jest.fn(),
|
||||
useSelect: jest.fn().mockReturnValue( {} ),
|
||||
};
|
||||
} );
|
||||
|
||||
useDispatch.mockReturnValue( {
|
||||
removeNotice: jest.fn(),
|
||||
|
|
|
@ -17,10 +17,6 @@ jest.mock( '@wordpress/data', () => {
|
|||
return {
|
||||
...originalModule,
|
||||
useDispatch: jest.fn(),
|
||||
// Mock dispatch to avoid errors for @wordpress/viewport listener.
|
||||
dispatch: jest.fn().mockReturnValue( {
|
||||
setIsMatching: jest.fn(),
|
||||
} ),
|
||||
};
|
||||
} );
|
||||
|
||||
|
|
|
@ -12,12 +12,30 @@ import { WooOnboardingTask } from '@woocommerce/onboarding';
|
|||
*/
|
||||
import { Task } from '../task';
|
||||
|
||||
jest.mock( '@wordpress/data' );
|
||||
jest.mock( '@wordpress/data', () => {
|
||||
// Require the original module to not be mocked...
|
||||
const originalModule = jest.requireActual( '@wordpress/data' );
|
||||
|
||||
jest.mock( '@woocommerce/navigation', () => ( {
|
||||
getHistory: jest.fn(),
|
||||
getNewPath: () => 'new-path',
|
||||
} ) );
|
||||
return {
|
||||
__esModule: true, // Use it when dealing with esModules
|
||||
...originalModule,
|
||||
useDispatch: jest.fn(),
|
||||
useSelect: jest.fn().mockReturnValue( {} ),
|
||||
};
|
||||
} );
|
||||
|
||||
jest.mock( '@woocommerce/navigation', () => {
|
||||
// Require the original module to not be mocked...
|
||||
const originalModule = jest.requireActual( '@woocommerce/navigation' );
|
||||
|
||||
return {
|
||||
__esModule: true, // Use it when dealing with esModules
|
||||
...originalModule,
|
||||
getPersistedQuery: jest.fn().mockReturnValue( {} ),
|
||||
getHistory: jest.fn(),
|
||||
getNewPath: () => 'new-path',
|
||||
};
|
||||
} );
|
||||
|
||||
jest.mock( '@woocommerce/onboarding', () => ( {
|
||||
WooOnboardingTask: {
|
||||
|
|
|
@ -12,7 +12,18 @@ import userEvent from '@testing-library/user-event';
|
|||
*/
|
||||
import { Tasks } from '../tasks';
|
||||
|
||||
jest.mock( '@wordpress/data' );
|
||||
jest.mock( '@wordpress/data', () => {
|
||||
// Require the original module to not be mocked...
|
||||
const originalModule = jest.requireActual( '@wordpress/data' );
|
||||
|
||||
return {
|
||||
__esModule: true, // Use it when dealing with esModules
|
||||
...originalModule,
|
||||
useDispatch: jest.fn().mockReturnValue( {} ),
|
||||
useSelect: jest.fn().mockReturnValue( {} ),
|
||||
};
|
||||
} );
|
||||
|
||||
jest.mock( '@woocommerce/explat' );
|
||||
jest.mock( '@woocommerce/tracks' );
|
||||
|
||||
|
|
Loading…
Reference in New Issue