({
- __esModule: true,
- default: {
- apiOrigin: "",
- options: jest.fn(),
- },
-}));
-
-jest.mock("fusion:properties", () =>
- jest.fn(() => ({
- api: {
- identity: {
- origin: "https://corecomponents-arc-demo-3-prod.api.cdn.arcpublishing.com",
- },
- retail: {
- origin: "https://corecomponents-arc-demo-3-prod.api.cdn.arcpublishing.com",
- endpoint: "/retail/public/v1/offer/live/",
- },
- },
- })),
-);
-
-jest.mock("fusion:context", () => ({
- __esModule: true,
- useFusionContext: () => ({
- arcSite: "Test Site",
- }),
-}));
-
-const orderDetails = {
- currency: "COP",
- shipping: 0,
- subtotal: 20000,
- tax: 100,
- taxSupported: true,
- total: 20100,
- items: [
- {
- name: "COP Currency",
- price: 20000,
- priceCode: "Q6R7UO",
- priceDescription: "with tax description price
",
- priceName: "All access Annual",
- priceSummary: "with tax summary price
",
- productDescription: "COP Currency description
",
- quantity: 1,
- shortDescription: "COP Currency description
",
- sku: "0987",
- subtotal: 20100,
- tax: 0,
- taxInclusive: undefined,
- total: 20000,
- productAttributes: [
- {
- featureText: "Unlimited access to The Daily Intelligencer
",
- },
- {
- featureText: "Save $40
",
- },
- {
- featureText: "A bonus subscription to share
",
- },
- ],
- },
- ],
-};
-
-describe("OfferCard", () => {
- it("renders order info", ()=>{
- render();
- expect(screen.getByText(orderDetails?.items?.[0]?.priceName)).toBeVisible();
- expect(screen.getByText("checkout-block.order-summary")).toBeVisible();
- expect(screen.getByText("checkout-block.subtotal")).toBeVisible();
- expect(screen.getByText(`${currency(orderDetails?.currency)}${orderDetails?.subtotal}`)).toBeVisible();
- expect(screen.getByText("checkout-block.salesTax")).toBeVisible();
- expect(screen.getByText(`${currency(orderDetails?.currency)}${orderDetails?.total}`)).toBeVisible();
- expect(screen.getByText("checkout-block.due-today")).toBeVisible();
- });
-
- it("renders price description", ()=>{
- render();
- expect(screen.getByText("with tax description price")).toBeVisible();
- });
-
- it("renders features", () => {
- render();
- const list = screen.getByRole("list")
- const { getAllByRole } = within(list)
- const items = getAllByRole("listitem")
- expect(items.length).toBe(3);
- });
-
- it("renders link to offer", ()=>{
- render();
- expect(screen.getByRole('link', { name: 'checkout-block.view-subscription-offers' })).toHaveAttribute('href', '/offer/');
- });
-});
diff --git a/blocks/subscriptions-block/components/OrderInformation/index.test.jsx b/blocks/subscriptions-block/components/OrderInformation/index.test.jsx
new file mode 100644
index 0000000000..bac4aabfbb
--- /dev/null
+++ b/blocks/subscriptions-block/components/OrderInformation/index.test.jsx
@@ -0,0 +1,141 @@
+import React from "react";
+import { render, screen, within } from "@testing-library/react";
+import '@testing-library/jest-dom';
+import OrderInformation from "./index";
+import currency from "../../utils/currency";
+
+const orderDetails = {
+ currency: "COP",
+ shipping: 0,
+ subtotal: 20000,
+ tax: 100,
+ taxSupported: true,
+ total: 20100,
+ items: [
+ {
+ name: "COP Currency",
+ price: 20000,
+ priceCode: "Q6R7UO",
+ priceDescription: "with tax description price
",
+ priceName: "All access Annual",
+ priceSummary: "with tax summary price
",
+ productDescription: "COP Currency description
",
+ quantity: 1,
+ shortDescription: "COP Currency description
",
+ sku: "0987",
+ subtotal: 20100,
+ tax: 0,
+ taxInclusive: undefined,
+ total: 20000,
+ productAttributes: [
+ {
+ featureText: "Unlimited access to The Daily Intelligencer
",
+ },
+ {
+ featureText: "Save $40
",
+ },
+ {
+ featureText: "A bonus subscription to share
",
+ },
+ ],
+ },
+ ],
+};
+
+jest.mock("@arc-publishing/sdk-identity", () => ({
+ __esModule: true,
+ default: {
+ apiOrigin: "",
+ options: jest.fn(),
+ },
+}));
+
+jest.mock("fusion:properties", () =>
+ jest.fn(() => ({
+ api: {
+ identity: {
+ origin: "https://corecomponents-arc-demo-3-prod.api.cdn.arcpublishing.com",
+ },
+ retail: {
+ origin: "https://corecomponents-arc-demo-3-prod.api.cdn.arcpublishing.com",
+ endpoint: "/retail/public/v1/offer/live/",
+ },
+ },
+ })),
+);
+
+jest.mock("fusion:context", () => ({
+ __esModule: true,
+ useFusionContext: () => ({
+ arcSite: "Test Site",
+ }),
+}));
+
+describe('Order Information component', () => {
+ it("renders order info", () => {
+ render(
+ ,
+ );
+ expect(screen.getByText(orderDetails?.items?.[0]?.priceName)).toBeVisible();
+ expect(screen.getByText("checkout-block.order-summary")).toBeVisible();
+ expect(screen.getByText("checkout-block.subtotal")).toBeVisible();
+ expect(
+ screen.getByText(`${currency(orderDetails?.currency)}${orderDetails?.subtotal}`),
+ ).toBeVisible();
+ expect(screen.getByText("checkout-block.salesTax")).toBeVisible();
+ expect(
+ screen.getByText(`${currency(orderDetails?.currency)}${orderDetails?.total}`),
+ ).toBeVisible();
+ expect(screen.getByText("checkout-block.due-today")).toBeVisible();
+ });
+
+ it("renders price description", () => {
+ render(
+ ,
+ );
+ expect(screen.getByText("with tax description price")).toBeVisible();
+ });
+
+ it("renders features", () => {
+ render(
+ ,
+ );
+ const list = screen.getByRole("list");
+ const { getAllByRole } = within(list);
+ const items = getAllByRole("listitem");
+ expect(items.length).toBe(3);
+ });
+
+ it("renders link to offer", () => {
+ render(
+ ,
+ );
+ expect(
+ screen.getByRole("link", { name: "checkout-block.view-subscription-offers" }),
+ ).toHaveAttribute("href", "/offer/");
+ });
+});
diff --git a/blocks/subscriptions-block/components/useOrder.jsx b/blocks/subscriptions-block/components/useOrder.jsx
index 3e0fc1fc26..44bffa0c9b 100644
--- a/blocks/subscriptions-block/components/useOrder.jsx
+++ b/blocks/subscriptions-block/components/useOrder.jsx
@@ -21,20 +21,21 @@ const useOrder = (orderNumber) => {
useEffect(() => {
const getCart = async () => {
- const cart = await Sales.getCart();
- setCart(cart);
+ const currentCart = await Sales.getCart();
+ setCart(currentCart);
};
getCart();
- const campaignName = localStorage.getItem(ARCXP_CAMPAIGN);
- setCampaignName(campaignName);
+ const campaignNameStored = localStorage.getItem(ARCXP_CAMPAIGN);
+ setCampaignName(campaignNameStored);
+ // eslint-disable-next-line
}, []);
useEffect(() => {
const getOrder = async () => {
try{
- const order = await Sales.getOrderDetails(orderNumber);
- setOrder(order);
+ const currentOrder = await Sales.getOrderDetails(orderNumber);
+ setOrder(currentOrder);
}catch(e){
setError(e);
}
@@ -42,6 +43,7 @@ const useOrder = (orderNumber) => {
if (orderNumber) {
getOrder();
}
+ // eslint-disable-next-line
}, [orderNumber]);
useEffect(() => {