Skip to content

Commit

Permalink
fix missing aria-label
Browse files Browse the repository at this point in the history
This PR is a follow up to paypal#2169 (29a18ec) that introduced
an issue related to the correct content not being available.
  • Loading branch information
jshawl committed Jun 15, 2023
1 parent d1896dc commit 5b09b3a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/funding/paypal/config.jsx
Expand Up @@ -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;
Expand Down
45 changes: 39 additions & 6 deletions test/integration/tests/button/style.js
Expand Up @@ -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: {
Expand All @@ -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: {
Expand All @@ -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();
});
});
});

0 comments on commit 5b09b3a

Please sign in to comment.