/** @jest-environment jsdom */
import { SafeDictionary } from "@insite/client-framework/Common/Types";
import setPageMetadata, { Metadata } from "@insite/client-framework/Common/Utilities/setPageMetadata";

describe("", () => {
    const alternateLanguageUrls: SafeDictionary<string> = {};
    alternateLanguageUrls["en-us"] = "https://localhost/Catalog/AllProducts";
    alternateLanguageUrls["fR-FR"] = "https://localhost/Catalogue/TousLesProduits";

    const data: Metadata = {
        metaDescription: "AllProducts",
        metaKeywords: "AllProducts AllProducts",
        openGraphImage: "",
        openGraphTitle: "",
        openGraphUrl: "",
        currentPath: "/Catalog/AllProducts",
        canonicalPath: "/Catalog/AllProducts",
        alternateLanguageUrls,
        websiteName: "_MainWebsite",
        currentQueryString: "?page=2",
        prevQueryString: "?page=1",
        nextQueryString: "?page=3",
    };

    test("There are links with relPrev,relnext ,relAlternate and relCanonical ", () => {
        setPageMetadata(data);
        expect(document.querySelector('link[rel="prev"]')).not.toBe(null);
        expect(document.querySelector('link[rel="next"]')).not.toBe(null);
        expect(document.querySelector('link[rel="alternate"]')).not.toBe(null);
        expect(document.querySelector('link[rel="canonical"]')).not.toBe(null);
        expect(document.getElementsByTagName("link")).toHaveLength(5);
    });
});
