refactor(payment): unify method selector visibility

This commit is contained in:
2026-07-20 16:14:48 +08:00
parent bc6373f4c0
commit 1f8bbe9022
4 changed files with 51 additions and 29 deletions
@@ -7,8 +7,11 @@ describe("PaymentMethodSelector", () => {
it("orders the default channel first and renders page analytics", () => {
const html = renderToStaticMarkup(
<PaymentMethodSelector
config={{
canChoosePaymentMethod: true,
initialPayChannel: "ezpay",
}}
value="ezpay"
defaultChannel="ezpay"
caption="GCash by default"
analyticsKey="tip.payment_method"
onChange={() => undefined}
@@ -40,6 +43,10 @@ describe("PaymentMethodSelector", () => {
it("disables both payment methods while payment is busy", () => {
const html = renderToStaticMarkup(
<PaymentMethodSelector
config={{
canChoosePaymentMethod: true,
initialPayChannel: "stripe",
}}
value="stripe"
disabled
analyticsKey="subscription.payment_method"
@@ -52,4 +59,20 @@ describe("PaymentMethodSelector", () => {
'data-analytics-key="subscription.payment_method"',
);
});
it("does not render when payment method selection is unavailable", () => {
const html = renderToStaticMarkup(
<PaymentMethodSelector
config={{
canChoosePaymentMethod: false,
initialPayChannel: "stripe",
}}
value="stripe"
analyticsKey="tip.payment_method"
onChange={() => undefined}
/>,
);
expect(html).toBe("");
});
});