File size: 1,537 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
/*
* @jest-environment jsdom
*/
import config from '@automattic/calypso-config';
import { SiteGoal, SiteIntent } from '../constants';
import { goalsToIntent } from '../utils';
jest.mock( '@automattic/calypso-config' );
describe( 'Test onboard utils', () => {
beforeEach( () => {
( config.isEnabled as jest.Mock ).mockReset();
} );
it.each( [
{
goals: [],
expectedIntent: SiteIntent.Build,
},
{
goals: [ SiteGoal.Write, SiteGoal.Import, SiteGoal.DIFM ],
expectedIntent: SiteIntent.DIFM,
},
{
goals: [ SiteGoal.Write, SiteGoal.Sell, SiteGoal.Promote ],
expectedIntent: SiteIntent.Sell,
},
{
goals: [ SiteGoal.Sell, SiteGoal.Write, SiteGoal.Promote ],
expectedIntent: SiteIntent.Sell,
},
{
goals: [ SiteGoal.Promote, SiteGoal.Sell, SiteGoal.Write ],
expectedIntent: SiteIntent.Sell,
},
{
goals: [ SiteGoal.Write, SiteGoal.Engagement ],
expectedIntent: SiteIntent.Write,
},
{
goals: [ SiteGoal.Write, SiteGoal.Newsletter ],
expectedIntent: SiteIntent.NewsletterGoal,
},
{
goals: [ SiteGoal.Sell, SiteGoal.Courses ],
expectedIntent: SiteIntent.CreateCourseGoal,
featureFlags: {
isIntentCreateCourseGoalEnabled: true,
},
},
{
goals: [ SiteGoal.Sell, SiteGoal.Newsletter ],
expectedIntent: SiteIntent.NewsletterGoal,
},
] )(
'Should map the $goals to $expectedIntent intent ($featureFlags)',
( { goals, expectedIntent, featureFlags } ) => {
expect( goalsToIntent( goals, featureFlags ) ).toBe( expectedIntent );
}
);
} );
|