Skip to content

Commit

Permalink
Improve test coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
nfmohit committed Sep 28, 2024
1 parent b835233 commit 9c0e918
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ describe( 'RRMSetupSuccessSubtleNotification', () => {
'^/google-site-kit/v1/modules/reader-revenue-manager/data/settings'
);

const setValueMock = jest.fn();

beforeEach( () => {
registry = createTestRegistry();

Expand All @@ -99,7 +101,6 @@ describe( 'RRMSetupSuccessSubtleNotification', () => {
] );

useQueryArg.mockImplementation( ( arg ) => {
const setValueMock = jest.fn();
switch ( arg ) {
case 'notification':
return [ 'authentication_success', setValueMock ];
Expand All @@ -113,6 +114,8 @@ describe( 'RRMSetupSuccessSubtleNotification', () => {
} );

afterEach( () => {
setValueMock.mockClear();
useQueryArg.mockClear();
global.open.mockClear();
} );

Expand Down Expand Up @@ -161,10 +164,6 @@ describe( 'RRMSetupSuccessSubtleNotification', () => {

const dismissElement = getByText( dismissText );
expect( dismissElement ).toBeInTheDocument();

act( () => {
fireEvent.click( ctaElement );
} );
}
);

Expand Down Expand Up @@ -208,6 +207,9 @@ describe( 'RRMSetupSuccessSubtleNotification', () => {
act( () => {
fireEvent.click( dismissElement );
} );

expect( setValueMock ).toHaveBeenCalledTimes( 2 );
expect( setValueMock ).toHaveBeenCalledWith( undefined );
}
);

Expand Down

0 comments on commit 9c0e918

Please sign in to comment.