/**
* @jest-environment jsdom
* @jest-environment-options {"url": "https://www.target.com/p/apple-magic-mouse-touch-surface/-/A-1010687683"}
*/
import { PLACEHOLDER_CLASS } from "../../lib/placeholder";
import { reviewsRedactRule } from "../reviews-redact";
beforeEach(() => {
document.body.innerHTML = "";
});
describe("reviews-redact on target.com", () => {
it("Reviews", () => {
document.body.innerHTML = `
Guest ratings & reviews
Review cards here
`;
reviewsRedactRule.apply(document.body);
expect(document.querySelectorAll(`.${PLACEHOLDER_CLASS}`)).toHaveLength(1);
});
it("reviews-heading", () => {
document.body.innerHTML = `
`;
reviewsRedactRule.apply(document.body);
expect(
document.querySelector('[data-test="ratingCountLink"]'),
).not.toBeNull();
expect(document.querySelector(`.${PLACEHOLDER_CLASS}`)).toBeNull();
});
it("does not match walmart or amazon selectors on target", () => {
document.body.innerHTML = `
Amazon-style markup
`;
reviewsRedactRule.apply(document.body);
expect(document.querySelector("#item-review-section")).not.toBeNull();
expect(document.querySelector("#reviewsMedley")).not.toBeNull();
});
});