-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created a unit test to ensure selector's behavior
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
client/state/selectors/test/should-show-launchpad-first.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ); | ||
} ); | ||
} ); |