diff --git a/spec/nosto.load.spec.tsx b/spec/nosto.load.spec.tsx new file mode 100644 index 0000000..6355a4b --- /dev/null +++ b/spec/nosto.load.spec.tsx @@ -0,0 +1,41 @@ +import React from "react" +import { vi, describe, expect, it } from "vitest" +import { render } from "@testing-library/react" +import { NostoProvider, NostoHome } from "../src/index" + +describe("Nosto client script loading", () => { + it("verify Nosto is not loaded twice", () => { + // @ts-expect-error dummy placeholder for Nosto iframe window scope + window.nosto = {} + + render( + + + + ) + + expect(document.querySelector("[nosto-client-script]")).not.toBeInTheDocument() + }) + + it("is loaded", () => { + render( + + + + ) + + expect(document.querySelector("[nosto-client-script]")).toBeInTheDocument() + }) + + it("Shopify markets script", () => { + render( + + + + ) + + expect(document.querySelector("[nosto-client-script]")).toBeInTheDocument() + expect(document.querySelector("[nosto-client-script]")?.getAttribute("nosto-language")).toBe("en") + expect(document.querySelector("[nosto-client-script]")?.getAttribute("nosto-market-id")).toBe("123") + }) +}) \ No newline at end of file diff --git a/spec/nosto.reload.spec.tsx b/spec/nosto.reload.spec.tsx deleted file mode 100644 index 6812e29..0000000 --- a/spec/nosto.reload.spec.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import React from "react" -import { test, expect } from "vitest" -import { render } from "@testing-library/react" -import { NostoProvider, NostoHome } from "../src/index" - -test("verify Nosto is not loaded twice", async () => { - // @ts-expect-error dummy placeholder for Nosto iframe window scope - window.nosto = {} - - render( - - - - ) - - expect(document.querySelector("[nosto-client-script]")).not.toBeInTheDocument() -})