File size: 1,996 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
64
65
66
67
68
69
70
71
72
import * as Actions from '../actions';
import * as MockData from '../mock';
import { buildPlanFeaturesDict } from '../test-utils';

const MOCK_LOCALE = 'test-locale';

describe( 'Plans action creators', () => {
	describe( 'setFeatures', () => {
		it( 'should create the correct action object', () => {
			const mockFeatures = buildPlanFeaturesDict( [
				MockData.STORE_PLAN_FEATURE_CUSTOM_DOMAIN,
				MockData.STORE_PLAN_FEATURE_LIVE_SUPPORT,
				MockData.STORE_PLAN_FEATURE_WORDADS,
			] );

			expect( Actions.setFeatures( mockFeatures, MOCK_LOCALE ) ).toEqual( {
				type: 'SET_FEATURES',
				features: mockFeatures,
				locale: MOCK_LOCALE,
			} );
		} );
	} );

	describe( 'setFeaturesByType', () => {
		it( 'should create the correct action object', () => {
			const features = [
				MockData.API_FEATURES_BY_TYPE_GENERAL,
				MockData.API_FEATURES_BY_TYPE_COMMERCE,
				MockData.API_FEATURES_BY_TYPE_MARKETING,
			];
			expect( Actions.setFeaturesByType( features, MOCK_LOCALE ) ).toEqual( {
				type: 'SET_FEATURES_BY_TYPE',
				featuresByType: features,
				locale: MOCK_LOCALE,
			} );
		} );
	} );

	describe( 'setPlans', () => {
		it( 'should create the correct action object', () => {
			const plans = [ MockData.STORE_PLAN_FREE, MockData.STORE_PLAN_PREMIUM ];
			expect( Actions.setPlans( plans, MOCK_LOCALE ) ).toEqual( {
				type: 'SET_PLANS',
				plans,
				locale: MOCK_LOCALE,
			} );
		} );
	} );

	describe( 'setPlanProducts', () => {
		it( 'should create the correct action object', () => {
			const planProducts = [
				MockData.STORE_PRODUCT_FREE,
				MockData.STORE_PRODUCT_PREMIUM_ANNUALLY,
				MockData.STORE_PRODUCT_PREMIUM_MONTHLY,
			];
			expect( Actions.setPlanProducts( planProducts ) ).toEqual( {
				type: 'SET_PLAN_PRODUCTS',
				products: planProducts,
			} );
		} );
	} );

	describe( 'resetPlan', () => {
		it( 'should create the correct action object', () => {
			expect( Actions.resetPlan() ).toEqual( {
				type: 'RESET_PLAN',
			} );
		} );
	} );
} );