Skip to content

Commit

Permalink
Merge pull request #100 from Nosto/add-nosto-load-spec
Browse files Browse the repository at this point in the history
Add Nosto client script load spec
  • Loading branch information
nosto-mikpou authored Aug 15, 2024
2 parents d3dec6b + b5d1f5f commit d235ee4
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 17 deletions.
41 changes: 41 additions & 0 deletions spec/nosto.load.spec.tsx
Original file line number Diff line number Diff line change
@@ -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(
<NostoProvider account="shopify-11368366139">
<NostoHome />
</NostoProvider>
)

expect(document.querySelector("[nosto-client-script]")).not.toBeInTheDocument()
})

it("is loaded", () => {
render(
<NostoProvider account="shopify-11368366139">
<NostoHome />
</NostoProvider>
)

expect(document.querySelector("[nosto-client-script]")).toBeInTheDocument()
})

it("Shopify markets script", () => {
render(
<NostoProvider account="shopify-11368366139" shopifyMarkets={{ language: "en", marketId: "123" }}>
<NostoHome />
</NostoProvider>
)

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")
})
})
17 changes: 0 additions & 17 deletions spec/nosto.reload.spec.tsx

This file was deleted.

0 comments on commit d235ee4

Please sign in to comment.