-
Notifications
You must be signed in to change notification settings - Fork 169
/
runtime_soild_test.ts
32 lines (27 loc) · 1.03 KB
/
runtime_soild_test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { assert, assertEquals } from "std/testing/asserts.ts";
import SolidTransformer from "../runtime/solid/transformer.ts";
Deno.test("[unit] loaders/solid.ts", async (t) => {
await t.step("SolidTransformer", async () => {
const testCode = `
import { render} from "https://esm.sh/solid-js/web";
import { createSignal } from "https://esm.sh/solid-js";
const foo = "foo";
function Counter() {
const [count, setCount] = createSignal(0);
const increment = () => setCount(count() + 1);
return (
<button type="button" onClick={increment}>
{count()}
</button>
);
}
render(() => <Counter />, document.getElementById("app")!);
`;
const transformer = new SolidTransformer();
const { lang, code } = await transformer.load("test.tsx", testCode, {});
assert(transformer.test("test.tsx"));
assertEquals(lang, "js");
assert(code.includes('_$template(`<button type="button"></button>`,'));
assert(code.includes("_$createComponent(Counter, {})"));
});
});