Skip to content

Commit 624373a

Browse files
committed
Unit test on Dashboard rather than CampaignCreationSuccessGuide
1 parent 06d689d commit 624373a

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

js/src/dashboard/campaign-creation-success-guide/index.test.js renamed to js/src/dashboard/index.test.js

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,18 @@ import { getQuery } from '@woocommerce/navigation';
99
/**
1010
* Internal dependencies
1111
*/
12-
import CampaignCreationSuccessGuide from './index';
12+
import Dashboard from './index';
1313
import isWCTracksEnabled from '.~/utils/isWCTracksEnabled';
1414
import { GUIDE_NAMES } from '.~/constants';
1515

16+
jest.mock( '@woocommerce/settings', () => {
17+
return {
18+
getSetting: () => ( {
19+
code: 'TWD',
20+
} ),
21+
};
22+
} );
23+
1624
jest.mock( '@woocommerce/navigation', () => {
1725
return {
1826
...jest.requireActual( '@woocommerce/navigation' ),
@@ -30,7 +38,12 @@ jest.mock( '.~/components/customer-effort-score-prompt', () => () => (
3038
<div>{ CES_PROMPT_TEXT }</div>
3139
) );
3240

33-
describe( 'CampaignCreationSuccessGuide', () => {
41+
beforeAll( () => {
42+
// Used in the js/src/hooks/useLegacyMenuEffect.js dependency
43+
window.wpNavMenuClassChange = jest.fn();
44+
} );
45+
46+
describe( 'Dashboard', () => {
3447
describe( `When the query string "guide" equals to ${ GUIDE_NAMES.CAMPAIGN_CREATION_SUCCESS }`, () => {
3548
beforeAll( () => {
3649
getQuery.mockImplementation( () => {
@@ -45,7 +58,7 @@ describe( 'CampaignCreationSuccessGuide', () => {
4558
} );
4659

4760
test( 'Should render CampaignCreationSuccessGuide', () => {
48-
const { queryByText } = render( <CampaignCreationSuccessGuide /> );
61+
const { queryByText } = render( <Dashboard /> );
4962
expect(
5063
queryByText( CAMPAIGN_CREATION_SUCCESS_GUIDE_TEXT )
5164
).toBeInTheDocument();
@@ -63,18 +76,14 @@ describe( 'CampaignCreationSuccessGuide', () => {
6376
} );
6477

6578
test( 'Should not render CustomerEffortScorePrompt when user does not click "Got it"', () => {
66-
const { queryByText } = render(
67-
<CampaignCreationSuccessGuide />
68-
);
79+
const { queryByText } = render( <Dashboard /> );
6980
expect(
7081
queryByText( CES_PROMPT_TEXT )
7182
).not.toBeInTheDocument();
7283
} );
7384

7485
test( 'Should not render CustomerEffortScorePrompt when user clicks "Got it"', () => {
75-
const { queryByText } = render(
76-
<CampaignCreationSuccessGuide />
77-
);
86+
const { queryByText } = render( <Dashboard /> );
7887
userEvent.click( screen.getByText( 'Got it' ) );
7988

8089
expect(
@@ -95,18 +104,14 @@ describe( 'CampaignCreationSuccessGuide', () => {
95104
} );
96105

97106
test( 'Should not render CustomerEffortScorePrompt when user does not click "Got it"', () => {
98-
const { queryByText } = render(
99-
<CampaignCreationSuccessGuide />
100-
);
107+
const { queryByText } = render( <Dashboard /> );
101108
expect(
102109
queryByText( CES_PROMPT_TEXT )
103110
).not.toBeInTheDocument();
104111
} );
105112

106113
test( 'Should render CustomerEffortScorePrompt when user clicks "Got it"', () => {
107-
const { queryByText } = render(
108-
<CampaignCreationSuccessGuide />
109-
);
114+
const { queryByText } = render( <Dashboard /> );
110115
userEvent.click( screen.getByText( 'Got it' ) );
111116

112117
expect( queryByText( CES_PROMPT_TEXT ) ).toBeInTheDocument();
@@ -126,7 +131,7 @@ describe( 'CampaignCreationSuccessGuide', () => {
126131
} );
127132

128133
test( 'Should not render CampaignCreationSuccessGuide', () => {
129-
const { queryByText } = render( <CampaignCreationSuccessGuide /> );
134+
const { queryByText } = render( <Dashboard /> );
130135
expect(
131136
queryByText( CAMPAIGN_CREATION_SUCCESS_GUIDE_TEXT )
132137
).not.toBeInTheDocument();

0 commit comments

Comments
 (0)