44 lines
1.8 KiB
JavaScript
44 lines
1.8 KiB
JavaScript
import { describe, expect, it } from "vitest";
|
|
import { listingRobots } from "@/lib/listingRobots";
|
|
|
|
const isNoindex = (result) => result?.robots?.index === false;
|
|
|
|
describe("listingRobots", () => {
|
|
it("صفحهٔ لیست بدون query ایندکسپذیر است", () => {
|
|
expect(isNoindex(listingRobots({}))).toBe(false);
|
|
expect(isNoindex(listingRobots(undefined))).toBe(false);
|
|
});
|
|
|
|
it("pagination ایندکسپذیر میماند (تصمیم M3-B)", () => {
|
|
expect(isNoindex(listingRobots({ page: "2" }))).toBe(false);
|
|
expect(isNoindex(listingRobots({ page: "38" }))).toBe(false);
|
|
});
|
|
|
|
it("هر فیلتر جستجو noindex میگیرد", () => {
|
|
expect(isNoindex(listingRobots({ specialty: "پوست و مو" }))).toBe(true);
|
|
expect(isNoindex(listingRobots({ name: "احمدی" }))).toBe(true);
|
|
expect(isNoindex(listingRobots({ gender: "woman" }))).toBe(true);
|
|
expect(isNoindex(listingRobots({ sort: "point" }))).toBe(true);
|
|
});
|
|
|
|
it("city/state حتی وقتی از لینک دامنهٔ خودی میآیند noindex میگیرند", () => {
|
|
const fromHomeSearch = { city: "یاسوج", state: "کهگیلویه و بویراحمد" };
|
|
expect(isNoindex(listingRobots(fromHomeSearch))).toBe(true);
|
|
});
|
|
|
|
it("فیلتر کنار page هم noindex میگیرد", () => {
|
|
expect(isNoindex(listingRobots({ specialty: "پوست و مو", page: "3" }))).toBe(true);
|
|
});
|
|
|
|
it("پارامتر با مقدار خالی فیلتر حساب نمیشود", () => {
|
|
expect(isNoindex(listingRobots({ specialty: "", name: undefined }))).toBe(false);
|
|
});
|
|
|
|
it("noindex همیشه با follow همراه است", () => {
|
|
expect(listingRobots({ name: "احمدی" }).robots).toEqual({
|
|
index: false,
|
|
follow: true,
|
|
});
|
|
});
|
|
});
|