@paypal/checkout-components 5.0.352 → 5.0.353
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/* @flow */
|
|
2
|
+
|
|
3
|
+
import { describe, expect, test } from "vitest";
|
|
4
|
+
|
|
5
|
+
import { BUTTON_COLOR, BUTTON_SIZE } from "../../../constants/button";
|
|
6
|
+
import { BUTTON_SIZE_STYLE } from "../config";
|
|
7
|
+
|
|
8
|
+
import { getResponsiveStyleVariables } from "./responsive";
|
|
9
|
+
|
|
10
|
+
// expected legacy responsive styles variables
|
|
11
|
+
const expectedLegacyResponsiveStylesTiny = {
|
|
12
|
+
style: BUTTON_SIZE_STYLE[BUTTON_SIZE.TINY],
|
|
13
|
+
buttonHeight: 25,
|
|
14
|
+
minDualWidth: 300,
|
|
15
|
+
textPercPercentage: 36,
|
|
16
|
+
smallerLabelHeight: 14,
|
|
17
|
+
labelHeight: 14,
|
|
18
|
+
pillBorderRadius: 13,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const expectedLegacyResponsiveStylesSmall = {
|
|
22
|
+
style: BUTTON_SIZE_STYLE[BUTTON_SIZE.SMALL],
|
|
23
|
+
buttonHeight: 25,
|
|
24
|
+
minDualWidth: 300,
|
|
25
|
+
textPercPercentage: 36,
|
|
26
|
+
smallerLabelHeight: 14,
|
|
27
|
+
labelHeight: 14,
|
|
28
|
+
pillBorderRadius: 13,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const expectedLegacyResponsiveStylesMedium = {
|
|
32
|
+
style: BUTTON_SIZE_STYLE[BUTTON_SIZE.MEDIUM],
|
|
33
|
+
buttonHeight: 35,
|
|
34
|
+
minDualWidth: 300,
|
|
35
|
+
textPercPercentage: 36,
|
|
36
|
+
smallerLabelHeight: 18,
|
|
37
|
+
labelHeight: 18,
|
|
38
|
+
pillBorderRadius: 18,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const expectedLegacyResponsiveStylesLarge = {
|
|
42
|
+
style: BUTTON_SIZE_STYLE[BUTTON_SIZE.LARGE],
|
|
43
|
+
buttonHeight: 45,
|
|
44
|
+
minDualWidth: 300,
|
|
45
|
+
textPercPercentage: 36,
|
|
46
|
+
smallerLabelHeight: 22,
|
|
47
|
+
labelHeight: 22,
|
|
48
|
+
pillBorderRadius: 23,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const expectedLegacyResponsiveStylesHuge = {
|
|
52
|
+
style: BUTTON_SIZE_STYLE[BUTTON_SIZE.HUGE],
|
|
53
|
+
buttonHeight: 55,
|
|
54
|
+
minDualWidth: 300,
|
|
55
|
+
textPercPercentage: 36,
|
|
56
|
+
smallerLabelHeight: 24,
|
|
57
|
+
labelHeight: 24,
|
|
58
|
+
pillBorderRadius: 28,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// expected rebranded responsive style variables
|
|
62
|
+
const expectedRebrandedResponsiveStylesTiny = {
|
|
63
|
+
style: BUTTON_SIZE_STYLE[BUTTON_SIZE.TINY],
|
|
64
|
+
buttonHeight: 25,
|
|
65
|
+
minDualWidth: 300,
|
|
66
|
+
textPercPercentage: 36,
|
|
67
|
+
smallerLabelHeight: 19,
|
|
68
|
+
labelHeight: 19,
|
|
69
|
+
pillBorderRadius: 13,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const expectedRebrandedResponsiveStylesSmall = {
|
|
73
|
+
style: BUTTON_SIZE_STYLE[BUTTON_SIZE.SMALL],
|
|
74
|
+
buttonHeight: 25,
|
|
75
|
+
minDualWidth: 300,
|
|
76
|
+
textPercPercentage: 36,
|
|
77
|
+
smallerLabelHeight: 19,
|
|
78
|
+
labelHeight: 19,
|
|
79
|
+
pillBorderRadius: 13,
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const expectedRebrandedResponsiveStylesMedium = {
|
|
83
|
+
style: BUTTON_SIZE_STYLE[BUTTON_SIZE.MEDIUM],
|
|
84
|
+
buttonHeight: 35,
|
|
85
|
+
minDualWidth: 300,
|
|
86
|
+
textPercPercentage: 36,
|
|
87
|
+
smallerLabelHeight: 27,
|
|
88
|
+
labelHeight: 27,
|
|
89
|
+
pillBorderRadius: 18,
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const expectedRebrandedResponsiveStylesLarge = {
|
|
93
|
+
style: BUTTON_SIZE_STYLE[BUTTON_SIZE.LARGE],
|
|
94
|
+
buttonHeight: 45,
|
|
95
|
+
minDualWidth: 300,
|
|
96
|
+
textPercPercentage: 36,
|
|
97
|
+
smallerLabelHeight: 34,
|
|
98
|
+
labelHeight: 34,
|
|
99
|
+
pillBorderRadius: 23,
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const expectedRebrandedResponsiveStylesHuge = {
|
|
103
|
+
style: BUTTON_SIZE_STYLE[BUTTON_SIZE.HUGE],
|
|
104
|
+
buttonHeight: 55,
|
|
105
|
+
minDualWidth: 300,
|
|
106
|
+
textPercPercentage: 36,
|
|
107
|
+
smallerLabelHeight: 42,
|
|
108
|
+
labelHeight: 42,
|
|
109
|
+
pillBorderRadius: 28,
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
describe("test responsive style variables for legacy", () => {
|
|
113
|
+
const experiment = {
|
|
114
|
+
isPaypalRebrandEnabled: false,
|
|
115
|
+
defaultBlueButtonColor: BUTTON_COLOR.GOLD,
|
|
116
|
+
};
|
|
117
|
+
const fundingEligibility = {
|
|
118
|
+
paypal: {
|
|
119
|
+
eligible: true,
|
|
120
|
+
branded: false,
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
test.each([
|
|
125
|
+
{ input: BUTTON_SIZE.TINY, expected: expectedLegacyResponsiveStylesTiny },
|
|
126
|
+
{ input: BUTTON_SIZE.SMALL, expected: expectedLegacyResponsiveStylesSmall },
|
|
127
|
+
{
|
|
128
|
+
input: BUTTON_SIZE.MEDIUM,
|
|
129
|
+
expected: expectedLegacyResponsiveStylesMedium,
|
|
130
|
+
},
|
|
131
|
+
{ input: BUTTON_SIZE.LARGE, expected: expectedLegacyResponsiveStylesLarge },
|
|
132
|
+
{ input: BUTTON_SIZE.HUGE, expected: expectedLegacyResponsiveStylesHuge },
|
|
133
|
+
])(
|
|
134
|
+
`should return legacy responsive styles for size $input`,
|
|
135
|
+
({ input, expected }) => {
|
|
136
|
+
expect(
|
|
137
|
+
getResponsiveStyleVariables({
|
|
138
|
+
experiment,
|
|
139
|
+
fundingEligibility,
|
|
140
|
+
size: input,
|
|
141
|
+
})
|
|
142
|
+
).toEqual(expected);
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
describe("test responsive style variables for rebrand light blue button", () => {
|
|
148
|
+
const experiment = {
|
|
149
|
+
isPaypalRebrandEnabled: true,
|
|
150
|
+
defaultBlueButtonColor: BUTTON_COLOR.DEFAULT_BLUE_LIGHT_BLUE,
|
|
151
|
+
};
|
|
152
|
+
const fundingEligibility = {
|
|
153
|
+
paypal: {
|
|
154
|
+
eligible: true,
|
|
155
|
+
branded: false,
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
test.each([
|
|
160
|
+
{
|
|
161
|
+
input: BUTTON_SIZE.TINY,
|
|
162
|
+
expected: expectedRebrandedResponsiveStylesTiny,
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
input: BUTTON_SIZE.SMALL,
|
|
166
|
+
expected: expectedRebrandedResponsiveStylesSmall,
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
input: BUTTON_SIZE.MEDIUM,
|
|
170
|
+
expected: expectedRebrandedResponsiveStylesMedium,
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
input: BUTTON_SIZE.LARGE,
|
|
174
|
+
expected: expectedRebrandedResponsiveStylesLarge,
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
input: BUTTON_SIZE.HUGE,
|
|
178
|
+
expected: expectedRebrandedResponsiveStylesHuge,
|
|
179
|
+
},
|
|
180
|
+
])(
|
|
181
|
+
`should return rebrand responsive styles for size $input`,
|
|
182
|
+
({ input, expected }) => {
|
|
183
|
+
expect(
|
|
184
|
+
getResponsiveStyleVariables({
|
|
185
|
+
experiment,
|
|
186
|
+
fundingEligibility,
|
|
187
|
+
size: input,
|
|
188
|
+
})
|
|
189
|
+
).toEqual(expected);
|
|
190
|
+
}
|
|
191
|
+
);
|
|
192
|
+
});
|