Skip to content

Commit

Permalink
add test for PayPal block
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardcho1231 committed Dec 4, 2023
1 parent d69b353 commit c270691
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions blocks/subscriptions-block/components/PayPal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export const PaypalCheckout = ({ labelOrderNumber, paypal, orderNumber, successU

return (
<>
<div>{token ? phrases.t("subscriptions-block.paypal-processing") : phrases.t("subscriptions-block.paypal-redirect-label")}</div>
<div>{error && phrases.t("subscriptions-block.payment-error") }</div>
<div data-testid="paypal-message-div">{token ? phrases.t("subscriptions-block.paypal-processing") : phrases.t("subscriptions-block.paypal-redirect-label")}</div>
<div data-testid="paypal-error-message-div">{error && phrases.t("subscriptions-block.payment-error") }</div>
</>
);
};
Expand Down
22 changes: 22 additions & 0 deletions blocks/subscriptions-block/components/PayPal/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from "react";
import { render, screen, act } from "@testing-library/react";

import PayPal from "./index";

it("renders", async () => {
await act(
async () => render(
<PayPal
labelOrderNumber = {"ArcSubs_OrderNumber"}
paypal = {{paymentMethodType: 10, paymentMethodID: 4339}}
orderNumber = "XAUEWT5S4PJJTAYY"
successURL = "/success"
isInitialized = {false}
/>
)
)

expect(screen.getByTestId('paypal-message-div').innerHTML).toBe('subscriptions-block.paypal-redirect-label');
expect(screen.getByTestId('paypal-error-message-div')).not.toBeNull();

});

0 comments on commit c270691

Please sign in to comment.