Skip to content

Commit

Permalink
Created a unit test to ensure selector's behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
paulopmt1 committed Jan 24, 2025
1 parent c3314f5 commit 27b2a3e
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions client/state/selectors/test/should-show-launchpad-first.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import config from '@automattic/calypso-config';
import { shouldShowLaunchpadFirst } from '../should-show-launchpad-first';

jest.mock( '@automattic/calypso-config', () => ( {
isEnabled: jest.fn(),
} ) );

describe( 'shouldShowLaunchpadFirst', () => {
beforeEach( () => {
jest.clearAllMocks();
} );

it( 'should return true when site was created via onboarding flow and feature flag is enabled', () => {
( config.isEnabled as jest.Mock ).mockReturnValue( true );
const site = {
options: {
site_creation_flow: 'onboarding',
},
};

expect( shouldShowLaunchpadFirst( site ) ).toBe( true );
} );

it( 'should return false when site was created via onboarding flow but feature flag is disabled', () => {
( config.isEnabled as jest.Mock ).mockReturnValue( false );
const site = {
options: {
site_creation_flow: 'onboarding',
},
};

expect( shouldShowLaunchpadFirst( site ) ).toBe( false );
} );

it( 'should return false when site was not created via onboarding flow', () => {
( config.isEnabled as jest.Mock ).mockReturnValue( true );
const site = {
options: {
site_creation_flow: 'other',
},
};

expect( shouldShowLaunchpadFirst( site ) ).toBe( false );
} );

it( 'should return false when site has no creation flow information', () => {
( config.isEnabled as jest.Mock ).mockReturnValue( true );
const site = {
options: {},
};

expect( shouldShowLaunchpadFirst( site ) ).toBe( false );
} );
} );

0 comments on commit 27b2a3e

Please sign in to comment.