Repository navigation
Fix PayPal button ignoring the Blue color #3725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -200,3 +200,44 @@ test( 'cancelling while another order is still in flight leaves Submit state alo | |
| assert.equal( result.running, 1 ); | ||
| assert.deepEqual( result.updated, [] ); | ||
| } ); | ||
|
|
||
| /** | ||
| * Run the real createPayPalButton() and return the config passed to paypal.Buttons(). | ||
| * | ||
| * @param {string} fundingSource The PayPal FUNDING constant. | ||
| * @param {string} color The saved button color. | ||
| * | ||
| * @return {Object} The button config. | ||
| */ | ||
| function createButtonConfig( fundingSource, color ) { | ||
| const start = source.indexOf( '\tfunction createPayPalButton(' ); | ||
| const end = source.indexOf( '\n\t// ---- Google Pay ----', start ); | ||
| assert.ok( start >= 0 && end > start, 'Button creation boundaries must exist.' ); | ||
| let config; | ||
| const context = { | ||
| frmPayPalVars: { buttonStyle: { color, label: 'paypal' } }, | ||
| paypal: { | ||
| Buttons: buttonConfig => { | ||
| config = buttonConfig; | ||
| } | ||
| }, | ||
| onApprove() {}, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| onError() {}, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| onCancel() {}, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| createOrder() {}, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| createSubscription() {}, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| }; | ||
| runInNewContext( `${ source.slice( start, end ) }\ncreatePayPalButton( fundingSource, false );`, { ...context, fundingSource } ); | ||
| return config; | ||
| } | ||
|
|
||
| test( 'the PayPal button keeps every color PayPal supports for it', () => { | ||
| [ 'gold', 'blue', 'silver', 'white', 'black' ].forEach( color => { | ||
| assert.equal( createButtonConfig( 'paypal', color ).style.color, color ); | ||
| } ); | ||
| } ); | ||
|
|
||
| test( 'a funding source drops a color it does not support', () => { | ||
| assert.equal( 'color' in createButtonConfig( 'venmo', 'gold' ).style, false ); | ||
| assert.equal( 'color' in createButtonConfig( 'paypal', 'purple' ).style, false ); | ||
| } ); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having empty functions hurts readability, and is considered a code-smell. There's almost always a way to avoid using them. If you must use one, consider adding a comment to inform the reader of its purpose.