@@ -11,6 +11,7 @@ import {
11
11
getElementRecursive ,
12
12
assert ,
13
13
WEBVIEW_USER_AGENT ,
14
+ mockProp ,
14
15
} from "../common" ;
15
16
16
17
for ( const flow of [ "popup" , "iframe" ] ) {
@@ -226,3 +227,107 @@ describe("paypal button aria-label", () => {
226
227
} ) ;
227
228
} ) ;
228
229
} ) ;
230
+
231
+ describe ( "paypal rebrand button" , ( ) => {
232
+ beforeEach ( ( ) => {
233
+ createTestContainer ( ) ;
234
+ } ) ;
235
+
236
+ afterEach ( ( ) => {
237
+ destroyTestContainer ( ) ;
238
+ } ) ;
239
+
240
+ it ( "should renders the legacy button when isPaypalRebrandEnabled is false" , ( ) => {
241
+ const mockPaypalRebrandExperiment = mockProp (
242
+ window . __TEST_FIRST_RENDER_EXPERIMENTS__ ,
243
+ "isPaypalRebrandEnabled" ,
244
+ false
245
+ ) ;
246
+
247
+ const button = window . paypal . Buttons ( { } ) ;
248
+
249
+ return button . render ( "#testContainer" ) . then ( ( ) => {
250
+ assert . ok ( getElementRecursive ( ".paypal-button-color-gold" ) ) ;
251
+ assert . ok (
252
+ getElementRecursive ( ".paypal-logo-paypal.paypal-logo-color-blue" )
253
+ ) ;
254
+ mockPaypalRebrandExperiment . cancel ( ) ;
255
+ } ) ;
256
+ } ) ;
257
+
258
+ it ( "should renders the legacy button when isPaypalRebrandEnabled is true and defaultBlueButtonColor is gold" , ( ) => {
259
+ const mockPaypalRebrandExperiment = mockProp (
260
+ window . __TEST_FIRST_RENDER_EXPERIMENTS__ ,
261
+ "isPaypalRebrandEnabled" ,
262
+ true
263
+ ) ;
264
+
265
+ const button = window . paypal . Buttons ( { } ) ;
266
+
267
+ return button . render ( "#testContainer" ) . then ( ( ) => {
268
+ assert . ok ( getElementRecursive ( ".paypal-button-color-gold" ) ) ;
269
+ assert . ok (
270
+ getElementRecursive ( ".paypal-logo-paypal.paypal-logo-color-blue" )
271
+ ) ;
272
+ mockPaypalRebrandExperiment . cancel ( ) ;
273
+ } ) ;
274
+ } ) ;
275
+
276
+ it ( "should renders the light-blue button when isPaypalRebrandEnabled is true and defaultBlueButtonColor is light-blue" , ( ) => {
277
+ const mockPaypalRebrandExperiment = mockProp (
278
+ window . __TEST_FIRST_RENDER_EXPERIMENTS__ ,
279
+ "isPaypalRebrandEnabled" ,
280
+ true
281
+ ) ;
282
+
283
+ const mockDefaultBlueColorExperiment = mockProp (
284
+ window . __TEST_FIRST_RENDER_EXPERIMENTS__ ,
285
+ "defaultBlueButtonColor" ,
286
+ "defaultBlue_lightBlue"
287
+ ) ;
288
+
289
+ const button = window . paypal . Buttons ( { } ) ;
290
+
291
+ return button . render ( "#testContainer" ) . then ( ( ) => {
292
+ assert . ok (
293
+ getElementRecursive ( ".paypal-button-color-defaultBlue_lightBlue" )
294
+ ) ;
295
+ assert . ok (
296
+ getElementRecursive (
297
+ ".paypal-logo-paypal-rebrand.paypal-logo-color-black"
298
+ )
299
+ ) ;
300
+ mockPaypalRebrandExperiment . cancel ( ) ;
301
+ mockDefaultBlueColorExperiment . cancel ( ) ;
302
+ } ) ;
303
+ } ) ;
304
+
305
+ it ( "should renders the dark-blue button when isPaypalRebrandEnabled is true and defaultBlueButtonColor is dark-blue" , ( ) => {
306
+ const mockPaypalRebrandExperiment = mockProp (
307
+ window . __TEST_FIRST_RENDER_EXPERIMENTS__ ,
308
+ "isPaypalRebrandEnabled" ,
309
+ true
310
+ ) ;
311
+
312
+ const mockDefaultBlueColorExperiment = mockProp (
313
+ window . __TEST_FIRST_RENDER_EXPERIMENTS__ ,
314
+ "defaultBlueButtonColor" ,
315
+ "defaultBlue_darkBlue"
316
+ ) ;
317
+
318
+ const button = window . paypal . Buttons ( { } ) ;
319
+
320
+ return button . render ( "#testContainer" ) . then ( ( ) => {
321
+ assert . ok (
322
+ getElementRecursive ( ".paypal-button-color-defaultBlue_darkBlue" )
323
+ ) ;
324
+ assert . ok (
325
+ getElementRecursive (
326
+ ".paypal-logo-paypal-rebrand.paypal-logo-color-blue"
327
+ )
328
+ ) ;
329
+ mockPaypalRebrandExperiment . cancel ( ) ;
330
+ mockDefaultBlueColorExperiment . cancel ( ) ;
331
+ } ) ;
332
+ } ) ;
333
+ } ) ;
0 commit comments