diff --git a/src/funding/paypal/config.jsx b/src/funding/paypal/config.jsx index fdaacd2a34..88760a9e59 100644 --- a/src/funding/paypal/config.jsx +++ b/src/funding/paypal/config.jsx @@ -54,7 +54,7 @@ export function getPayPalConfig(): FundingSourceConfig { } else { text = content["label.installment.withoutPeriod"]; } - } else if (content && label) { + } else if (content && label && content[`label.${label}`]) { text = content[`label.${label}`]; } return text; diff --git a/test/integration/tests/button/style.js b/test/integration/tests/button/style.js index 546986fe99..d78e06438e 100644 --- a/test/integration/tests/button/style.js +++ b/test/integration/tests/button/style.js @@ -137,7 +137,15 @@ describe("paypal button color", () => { }); describe("paypal button aria-label", () => { - it("uses style.label and style.period", () => { + beforeEach(() => { + createTestContainer(); + }); + + afterEach(() => { + destroyTestContainer(); + }); + + it("uses style.label and style.period", (done) => { window.paypal .Buttons({ content: { @@ -152,11 +160,14 @@ describe("paypal button aria-label", () => { .render("#testContainer") .then(() => { assert.ok( - getElementRecursive("[aria-label='Pay up to 3x without interest']") + getElementRecursive( + ".paypal-button[aria-label='Pay up to 3x without interest']" + ) ); + done(); }); }); - it("handles style.label == 'installment' without style.period", () => { + it("handles style.label == 'installment' without style.period", (done) => { window.paypal .Buttons({ content: { @@ -168,19 +179,41 @@ describe("paypal button aria-label", () => { }) .render("#testContainer") .then(() => { - assert.ok(getElementRecursive("[aria-label='Interest free payments']")); + assert.ok( + getElementRecursive( + ".paypal-button[aria-label='Interest free payments']" + ) + ); + done(); + }); + }); + it("falls back to the funding source if content is unavailable", (done) => { + window.paypal + .Buttons({ + style: { + label: "buynow", + }, + }) + .render("#testContainer") + .then(() => { + assert.ok(getElementRecursive(".paypal-button[aria-label='PayPal']")); + done(); }); }); - it("falls back to the funding source if content is unavailable", () => { + it("falls back to the funding source if the correct content is unavailable", (done) => { window.paypal .Buttons({ + content: { + "label.pay": "Pay with PayPal", + }, style: { label: "buynow", }, }) .render("#testContainer") .then(() => { - assert.ok(getElementRecursive("[aria-label='PayPal']")); + assert.ok(getElementRecursive(".paypal-button[aria-label='PayPal']")); + done(); }); }); });