-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6afbbd0
commit 17bdf3c
Showing
2 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { test, expect } from "vitest" | ||
import { renderToString } from "react-dom/server" | ||
import { NostoProvider, NostoHome, NostoPlacement } from "../src/index" | ||
import RecommendationComponent from "./renderer" | ||
|
||
test("Home page server-side render", async () => { | ||
const origWindow = global.window | ||
try { | ||
// @ts-expect-error SSR emulation | ||
global.window = undefined | ||
|
||
const html = renderToString( | ||
<NostoProvider account="dummy-account" recommendationComponent={<RecommendationComponent />} loadScript={true}> | ||
<NostoPlacement id="frontpage-nosto-1" /> | ||
<NostoPlacement id="frontpage-nosto-2" /> | ||
<NostoHome /> | ||
</NostoProvider> | ||
) | ||
|
||
// Check if the rendered HTML contains the expected elements | ||
expect(html).toContain('id="frontpage-nosto-1"') | ||
expect(html).toContain('id="frontpage-nosto-2"') | ||
} finally { | ||
global.window = origWindow | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters