Skip to content

Commit 3b184d3

Browse files
committed
Add tests
1 parent a67dfdd commit 3b184d3

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

apps/tests/src/e2e/server-function.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,9 @@ test.describe("server-function", () => {
6767
await page.goto("http://localhost:3000/generator-server-function");
6868
await expect(page.locator("#server-fn-test")).toContainText("¡Hola, Mundo!");
6969
});
70+
71+
test("should build with a server function ping", async ({ page }) => {
72+
await page.goto("http://localhost:3000/server-function-ping");
73+
await expect(page.locator("#server-fn-test")).toContainText('{"result":true}');
74+
});
7075
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { createEffect, createSignal } from "solid-js";
2+
3+
async function ping(value: string) {
4+
"use server";
5+
6+
return await Promise.resolve(value);
7+
}
8+
9+
export default function App() {
10+
const [output, setOutput] = createSignal<{ result?: boolean }>({});
11+
12+
createEffect(async () => {
13+
const value = `${Math.random() * 1000}`;
14+
const result = await ping(value);
15+
setOutput(prev => ({ ...prev, result: value === result }));
16+
});
17+
18+
return (
19+
<main>
20+
<span id="server-fn-test">{JSON.stringify(output())}</span>
21+
</main>
22+
);
23+
}

0 commit comments

Comments
 (0)