forked from Automattic/wp-calypso
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplan-levels-match.js
107 lines (102 loc) · 4.13 KB
/
plan-levels-match.js
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/* eslint jest/expect-expect: ["error", { "assertFunctionNames": ["testPlansArrayIndependentOfOrder"] }] */
import { planLevelsMatch } from '../src';
import {
PLAN_BUSINESS_MONTHLY,
PLAN_BUSINESS,
PLAN_BUSINESS_2_YEARS,
PLAN_BUSINESS_3_YEARS,
PLAN_FREE,
PLAN_JETPACK_BUSINESS,
PLAN_JETPACK_BUSINESS_MONTHLY,
PLAN_JETPACK_FREE,
PLAN_JETPACK_PERSONAL,
PLAN_JETPACK_PERSONAL_MONTHLY,
PLAN_JETPACK_PREMIUM,
PLAN_JETPACK_PREMIUM_MONTHLY,
PLAN_PERSONAL,
PLAN_PERSONAL_2_YEARS,
PLAN_PERSONAL_3_YEARS,
PLAN_BLOGGER,
PLAN_BLOGGER_2_YEARS,
PLAN_PREMIUM,
PLAN_PREMIUM_2_YEARS,
PLAN_PREMIUM_3_YEARS,
} from '../src/constants';
describe( 'planLevelsMatch', () => {
const testPlansArrayIndependentOfOrder = ( plansArray, result ) =>
plansArray.forEach( ( [ slugA, slugB ] ) => {
expect( planLevelsMatch( slugA, slugB ) ).toBe[ result ];
expect( planLevelsMatch( slugB, slugA ) ).toBe[ result ];
} );
test( 'should return true for identical plans', () => {
const identicalPlans = [
[ PLAN_BUSINESS_MONTHLY, PLAN_BUSINESS_MONTHLY ],
[ PLAN_BUSINESS, PLAN_BUSINESS ],
[ PLAN_BUSINESS_2_YEARS, PLAN_BUSINESS_2_YEARS ],
[ PLAN_BUSINESS_3_YEARS, PLAN_BUSINESS_3_YEARS ],
[ PLAN_FREE, PLAN_FREE ],
[ PLAN_JETPACK_BUSINESS, PLAN_JETPACK_BUSINESS ],
[ PLAN_JETPACK_BUSINESS_MONTHLY, PLAN_JETPACK_BUSINESS_MONTHLY ],
[ PLAN_JETPACK_FREE, PLAN_JETPACK_FREE ],
[ PLAN_JETPACK_PERSONAL, PLAN_JETPACK_PERSONAL ],
[ PLAN_JETPACK_PERSONAL_MONTHLY, PLAN_JETPACK_PERSONAL_MONTHLY ],
[ PLAN_JETPACK_PREMIUM, PLAN_JETPACK_PREMIUM ],
[ PLAN_JETPACK_PREMIUM_MONTHLY, PLAN_JETPACK_PREMIUM_MONTHLY ],
[ PLAN_PERSONAL, PLAN_PERSONAL ],
[ PLAN_PERSONAL_2_YEARS, PLAN_PERSONAL_2_YEARS ],
[ PLAN_PERSONAL_3_YEARS, PLAN_PERSONAL_3_YEARS ],
[ PLAN_BLOGGER, PLAN_BLOGGER ],
[ PLAN_BLOGGER_2_YEARS, PLAN_BLOGGER_2_YEARS ],
[ PLAN_PREMIUM, PLAN_PREMIUM ],
[ PLAN_PREMIUM_2_YEARS, PLAN_PREMIUM_2_YEARS ],
[ PLAN_PREMIUM_3_YEARS, PLAN_PREMIUM_3_YEARS ],
];
testPlansArrayIndependentOfOrder( identicalPlans, 'true' );
} );
test( 'should return true for matching plans', () => {
const matchingPlans = [
[ PLAN_BUSINESS_MONTHLY, PLAN_BUSINESS ],
[ PLAN_BUSINESS_MONTHLY, PLAN_BUSINESS_3_YEARS ],
[ PLAN_JETPACK_BUSINESS, PLAN_JETPACK_BUSINESS_MONTHLY ],
[ PLAN_JETPACK_PERSONAL, PLAN_JETPACK_PERSONAL_MONTHLY ],
[ PLAN_JETPACK_PREMIUM, PLAN_JETPACK_PREMIUM_MONTHLY ],
];
testPlansArrayIndependentOfOrder( matchingPlans, 'true' );
} );
test( 'should return false for non-matching plans', () => {
const nonMatchingPlans = [
[ PLAN_JETPACK_BUSINESS, PLAN_BUSINESS ],
[ PLAN_JETPACK_BUSINESS, PLAN_BUSINESS_2_YEARS ],
[ PLAN_JETPACK_BUSINESS, PLAN_BUSINESS_3_YEARS ],
[ PLAN_JETPACK_BUSINESS, PLAN_FREE ],
[ PLAN_JETPACK_BUSINESS_MONTHLY, PLAN_BUSINESS_MONTHLY ],
[ PLAN_JETPACK_BUSINESS, PLAN_JETPACK_PERSONAL_MONTHLY ],
[ PLAN_JETPACK_BUSINESS, PLAN_JETPACK_PREMIUM_MONTHLY ],
[ PLAN_JETPACK_BUSINESS, PLAN_PERSONAL ],
[ PLAN_JETPACK_BUSINESS, PLAN_PERSONAL_2_YEARS ],
[ PLAN_JETPACK_BUSINESS, PLAN_PREMIUM_2_YEARS ],
[ PLAN_JETPACK_BUSINESS, PLAN_PREMIUM ],
[ PLAN_JETPACK_PERSONAL, PLAN_BUSINESS ],
[ PLAN_JETPACK_PERSONAL, PLAN_FREE ],
[ PLAN_JETPACK_PERSONAL, PLAN_JETPACK_BUSINESS_MONTHLY ],
[ PLAN_JETPACK_PERSONAL, PLAN_JETPACK_PREMIUM_MONTHLY ],
[ PLAN_JETPACK_PERSONAL, PLAN_PERSONAL ],
[ PLAN_JETPACK_PERSONAL, PLAN_PERSONAL_2_YEARS ],
[ PLAN_JETPACK_PERSONAL, PLAN_PREMIUM ],
[ PLAN_JETPACK_PERSONAL, PLAN_PREMIUM_2_YEARS ],
[ PLAN_JETPACK_PERSONAL, PLAN_BLOGGER ],
[ PLAN_JETPACK_PERSONAL, PLAN_BLOGGER_2_YEARS ],
[ PLAN_JETPACK_PREMIUM, PLAN_BUSINESS ],
[ PLAN_JETPACK_PREMIUM, PLAN_FREE ],
[ PLAN_JETPACK_PREMIUM, PLAN_JETPACK_BUSINESS_MONTHLY ],
[ PLAN_JETPACK_PREMIUM, PLAN_JETPACK_PERSONAL_MONTHLY ],
[ PLAN_JETPACK_PREMIUM, PLAN_PERSONAL ],
[ PLAN_JETPACK_PREMIUM, PLAN_PERSONAL_2_YEARS ],
[ PLAN_JETPACK_PREMIUM, PLAN_BLOGGER ],
[ PLAN_JETPACK_PREMIUM, PLAN_BLOGGER_2_YEARS ],
[ PLAN_JETPACK_PREMIUM, PLAN_PREMIUM ],
[ PLAN_JETPACK_PREMIUM, PLAN_PREMIUM_2_YEARS ],
];
testPlansArrayIndependentOfOrder( nonMatchingPlans, 'false' );
} );
} );