Skip to content

Commit

Permalink
Update tests to also mock the canInstallPlugins
Browse files Browse the repository at this point in the history
Similar to the other mocks in these tests.
  • Loading branch information
renatho committed Oct 24, 2024
1 parent 456d3aa commit 84a44ec
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions client/hosting/overview/components/test/migration-overview.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
/**
* @jest-environment jsdom
*/
import { canInstallPlugins } from '@automattic/sites';
import { render } from '@testing-library/react';
import React from 'react';
import { getMigrationStatus, getMigrationType } from 'calypso/sites-dashboard/utils';
import MigrationOverview from '../migration-overview';
import type { SiteDetails, SiteDetailsPlan } from '@automattic/data-stores';
import type { SiteDetails } from '@automattic/data-stores';

jest.mock( '@automattic/sites' );
jest.mock( 'calypso/sites-dashboard/utils' );
jest.mock( '@automattic/calypso-products' );

describe( 'MigrationOverview', () => {
beforeEach( () => {
( getMigrationStatus as jest.Mock ).mockReturnValue( 'pending' );
} );

it.each( [
[
'diy',
Expand Down Expand Up @@ -48,15 +45,14 @@ describe( 'MigrationOverview', () => {
],
] )(
'should set continueMigrationUrl correctly for migrationType: %s and isFreePlan: %s',
( migrationType, canInstallPlugins, expectedUrl ) => {
( migrationType, siteCanInstallPlugins, expectedUrl ) => {
( getMigrationType as jest.Mock ).mockReturnValue( migrationType );
( getMigrationStatus as jest.Mock ).mockReturnValue( 'pending' );
( canInstallPlugins as jest.Mock ).mockReturnValue( siteCanInstallPlugins );

const site = {
ID: 123,
slug: 'example.com',
plan: {
features: { active: canInstallPlugins ? [ 'install-plugins' ] : [] },
} as SiteDetailsPlan,
} as SiteDetails;

const { getByText } = render( <MigrationOverview site={ site } /> );
Expand Down

0 comments on commit 84a44ec

Please sign in to comment.