Skip to content

Commit

Permalink
THEMES-967: saving work
Browse files Browse the repository at this point in the history
  • Loading branch information
vgalatro committed Oct 17, 2023
1 parent 2ae7422 commit 7403f62
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 24 deletions.
2 changes: 1 addition & 1 deletion blocks/ads-block/features/ads/default.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const ArcAdDisplay = (props) => {
offsetLeft={0}
offsetRight={0}
offsetTop={200}
renderPlaceholder={(ref) => <div ref={ref} />}
renderPlaceholder={(ref) => <div data-testid="lazy-load-placeholder" ref={ref} />}
>
<AdUnit adConfig={config} featureConfig={propsWithContext} />
</LazyLoad>
Expand Down
31 changes: 8 additions & 23 deletions blocks/ads-block/features/ads/default.test.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { useFusionContext } from "fusion:context";
import { mount } from "enzyme";
import { render, screen } from "@testing-library/react";
import ArcAd from "./default";

jest.mock("@wpmedia/arc-themes-components", () => ({
Expand Down Expand Up @@ -45,14 +45,9 @@ describe("<ArcAd>", () => {
});

it("renders no ad unit in admin dashboard", () => {
const wrapper = mount(<ArcAd {...AD_PROPS_MOCK} />);
expect(wrapper).toBeDefined();
const arcAdminAd = wrapper.find("ArcAdminAd");
expect(arcAdminAd.prop("adClass")).toEqual(AD_PROPS_MOCK.customFields.adType);
expect(arcAdminAd.prop("adType")).toEqual("cube");
expect(arcAdminAd.prop("slotName")).toEqual("news");
expect(typeof arcAdminAd.prop("dimensions")).toEqual("object");
expect(wrapper.find("AdUnit")).toHaveLength(0);
render(<ArcAd {...AD_PROPS_MOCK} />);
expect(screen.getByText("cube")).not.toBeNull();
expect(screen.queryByText(/ads-block.ad-label/)).toBeNull();
});
});

Expand All @@ -67,15 +62,8 @@ describe("<ArcAd>", () => {

describe("when lazy loading is disabled", () => {
it("renders ad unit with disabled lazy-load container", () => {
const wrapper = mount(<ArcAd {...AD_PROPS_MOCK} />);
expect(wrapper).toBeDefined();
const lazyLoaderEl = wrapper.find("LazyLoad");
expect(lazyLoaderEl).toHaveLength(1);
expect(lazyLoaderEl.prop("enabled")).toBe(false);
const adUnitEl = lazyLoaderEl.find("AdUnit");
expect(adUnitEl).toHaveLength(1);
expect(typeof adUnitEl.prop("adConfig")).toEqual("object");
expect(typeof adUnitEl.prop("featureConfig")).toEqual("object");
render(<ArcAd {...AD_PROPS_MOCK} />);
expect(screen.getByText(/ads-block.ad-label/)).not.toBeNull();
});
});

Expand All @@ -87,11 +75,8 @@ describe("<ArcAd>", () => {
lazyLoad: true,
},
};
const wrapper = mount(<ArcAd {...adProps} />);
expect(wrapper).toBeDefined();
const lazyLoaderEl = wrapper.find("LazyLoad");
expect(lazyLoaderEl).toHaveLength(1);
expect(lazyLoaderEl.prop("enabled")).toBe(true);
render(<ArcAd {...adProps} />);
expect(screen.getByTestId("lazy-load-placeholder")).not.toBeNull();
});
});
});
Expand Down

0 comments on commit 7403f62

Please sign in to comment.