@luna_ui/luna 0.7.3 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-DAWeanTX.js +1 -0
- package/dist/api-qXll116-.d.ts +80 -0
- package/dist/cli.mjs +27 -22
- package/dist/css/index.js +1 -0
- package/dist/event-utils.d.ts +1 -1
- package/dist/event-utils.js +1 -1
- package/dist/{index-vO066aMd.d.ts → index-VY8G32hr.d.ts} +16 -76
- package/dist/index.d.ts +4 -3
- package/dist/index.js +1 -1
- package/dist/jsx-dev-runtime.js +1 -1
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/jsx-runtime.js +1 -1
- package/dist/raw.d.ts +2 -0
- package/dist/raw.js +1 -0
- package/dist/resource.d.ts +41 -0
- package/dist/resource.js +1 -0
- package/dist/router-lite.d.ts +44 -0
- package/dist/router-lite.js +1 -0
- package/dist/signals-shared.d.ts +12 -0
- package/dist/signals-shared.js +1 -0
- package/dist/signals.d.ts +50 -0
- package/dist/signals.js +1 -0
- package/dist/vite-plugin.d.ts +7708 -2
- package/dist/vite-plugin.js +7 -6
- package/package.json +34 -11
- package/dist/event-utils-C_M2XBNj.js +0 -1
- package/dist/src-BbjOW18q.js +0 -1
- package/src/css/extract.ts +0 -798
- package/src/css/index.ts +0 -10
- package/src/css/inject.ts +0 -205
- package/src/css/inline.ts +0 -182
- package/src/css/minify.ts +0 -70
- package/src/css/optimizer.ts +0 -6
- package/src/css/runtime.ts +0 -344
- package/src/css-optimizer/README.md +0 -353
- package/src/css-optimizer/cooccurrence.ts +0 -100
- package/src/css-optimizer/core.ts +0 -263
- package/src/css-optimizer/extractors.ts +0 -243
- package/src/css-optimizer/hash.ts +0 -54
- package/src/css-optimizer/index.ts +0 -129
- package/src/css-optimizer/merge.ts +0 -109
- package/src/css-optimizer/moonbit-analyzer.ts +0 -210
- package/src/css-optimizer/parser.ts +0 -120
- package/src/css-optimizer/pattern.ts +0 -171
- package/src/css-optimizer/transformers.ts +0 -301
- package/src/css-optimizer/types.ts +0 -128
- package/src/event-utils.ts +0 -227
- package/src/hydration/createHydrator.ts +0 -62
- package/src/hydration/delegate.ts +0 -62
- package/src/hydration/drag.ts +0 -214
- package/src/hydration/index.ts +0 -12
- package/src/hydration/keyboard.ts +0 -64
- package/src/hydration/toggle.ts +0 -101
- package/src/index.ts +0 -908
- package/src/jsx-dev-runtime.ts +0 -2
- package/src/jsx-runtime.ts +0 -398
- package/src/vite-plugin.ts +0 -718
- package/tests/__screenshots__/apg.test.ts/APG-Components---Accessibility-Tests-Button-Pattern-disabled-button-has-aria-disabled-1.png +0 -0
- package/tests/apg.test.ts +0 -466
- package/tests/context.test.ts +0 -118
- package/tests/css-optimizer-extractors.test.ts +0 -264
- package/tests/css-optimizer-integration.test.ts +0 -566
- package/tests/css-optimizer-transformers.test.ts +0 -301
- package/tests/css-optimizer.test.ts +0 -646
- package/tests/css-runtime.bench.ts +0 -442
- package/tests/css-runtime.test.ts +0 -342
- package/tests/debounced.test.ts +0 -165
- package/tests/dom.test.ts +0 -873
- package/tests/integration.test.ts +0 -405
- package/tests/issue-11-show-null-to-truthy.test.ts +0 -176
- package/tests/issue-5-for-infinite-loop.test.ts +0 -516
- package/tests/jsx-runtime.test.tsx +0 -393
- package/tests/lifecycle.test.ts +0 -833
- package/tests/move-before.bench.ts +0 -304
- package/tests/preact-signals-comparison.test.ts +0 -1608
- package/tests/resource.test.ts +0 -160
- package/tests/router.test.ts +0 -117
- package/tests/show-initial-mount-leak.test.tsx +0 -182
- package/tests/solidjs-api.test.ts +0 -660
- package/tests/static-perf.bench.ts +0 -64
- package/tests/store.test.ts +0 -263
- package/tests/tsx-syntax.test.tsx +0 -404
- /package/dist/{event-utils-Cd5f3Njd.d.ts → event-utils-BvAf0NwN.d.ts} +0 -0
package/tests/resource.test.ts
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect, vi } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
createResource,
|
|
4
|
-
createDeferred,
|
|
5
|
-
createRenderEffect,
|
|
6
|
-
createRoot,
|
|
7
|
-
} from "../src/index";
|
|
8
|
-
|
|
9
|
-
describe("Resource API (SolidJS-style)", () => {
|
|
10
|
-
describe("createResource", () => {
|
|
11
|
-
test("starts in pending state", () => {
|
|
12
|
-
const [resource] = createResource<string>(() => {
|
|
13
|
-
// Never resolves
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
expect(resource.loading).toBe(true);
|
|
17
|
-
expect(resource.state).toBe("pending");
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
test("transitions to success on resolve", async () => {
|
|
21
|
-
const [resource] = createResource<string>((resolve) => {
|
|
22
|
-
resolve("success-data");
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// Resolve happens synchronously in this case
|
|
26
|
-
expect(resource.state).toBe("ready");
|
|
27
|
-
expect(resource()).toBe("success-data");
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test("transitions to failure on reject", () => {
|
|
31
|
-
const [resource] = createResource<string>((_, reject) => {
|
|
32
|
-
reject("error-message");
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
expect(resource.state).toBe("errored");
|
|
36
|
-
expect(resource.error).toBe("error-message");
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
test("async resolve works", async () => {
|
|
40
|
-
let resolveRef: ((value: string) => void) | null = null;
|
|
41
|
-
|
|
42
|
-
const [resource] = createResource<string>((resolve) => {
|
|
43
|
-
resolveRef = resolve;
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
expect(resource.loading).toBe(true);
|
|
47
|
-
|
|
48
|
-
resolveRef!("async-data");
|
|
49
|
-
|
|
50
|
-
expect(resource.state).toBe("ready");
|
|
51
|
-
expect(resource()).toBe("async-data");
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
test("refetch re-runs fetcher", () => {
|
|
55
|
-
let fetchCount = 0;
|
|
56
|
-
const [resource, { refetch }] = createResource<string>((resolve) => {
|
|
57
|
-
fetchCount++;
|
|
58
|
-
resolve(`fetch-${fetchCount}`);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
expect(fetchCount).toBe(1);
|
|
62
|
-
expect(resource()).toBe("fetch-1");
|
|
63
|
-
|
|
64
|
-
refetch();
|
|
65
|
-
|
|
66
|
-
expect(fetchCount).toBe(2);
|
|
67
|
-
expect(resource()).toBe("fetch-2");
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
describe("createDeferred", () => {
|
|
72
|
-
test("returns accessor, resolve, and reject", () => {
|
|
73
|
-
const [resource, resolve, reject] = createDeferred<number>();
|
|
74
|
-
|
|
75
|
-
expect(typeof resource).toBe("function");
|
|
76
|
-
expect(typeof resolve).toBe("function");
|
|
77
|
-
expect(typeof reject).toBe("function");
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
test("starts in pending state", () => {
|
|
81
|
-
const [resource] = createDeferred<number>();
|
|
82
|
-
expect(resource.loading).toBe(true);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
test("resolve transitions to success", () => {
|
|
86
|
-
const [resource, resolve] = createDeferred<number>();
|
|
87
|
-
|
|
88
|
-
resolve(42);
|
|
89
|
-
|
|
90
|
-
expect(resource.loading).toBe(false);
|
|
91
|
-
expect(resource()).toBe(42);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
test("reject transitions to failure", () => {
|
|
95
|
-
const [resource, , reject] = createDeferred<number>();
|
|
96
|
-
|
|
97
|
-
reject("deferred-error");
|
|
98
|
-
|
|
99
|
-
expect(resource.loading).toBe(false);
|
|
100
|
-
expect(resource.error).toBe("deferred-error");
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
describe("reactivity", () => {
|
|
105
|
-
test("accessor is reactive", () => {
|
|
106
|
-
const [resource, resolve] = createDeferred<string>();
|
|
107
|
-
let effectRunCount = 0;
|
|
108
|
-
|
|
109
|
-
createRoot((dispose) => {
|
|
110
|
-
createRenderEffect(() => {
|
|
111
|
-
resource(); // Access value to track
|
|
112
|
-
effectRunCount++;
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
expect(effectRunCount).toBe(1);
|
|
116
|
-
|
|
117
|
-
resolve("data");
|
|
118
|
-
// Effect should re-run because accessor is reactive
|
|
119
|
-
expect(effectRunCount).toBe(2);
|
|
120
|
-
dispose();
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
describe("integration with Promise", () => {
|
|
126
|
-
test("works with setTimeout simulation", async () => {
|
|
127
|
-
vi.useFakeTimers();
|
|
128
|
-
|
|
129
|
-
const [resource] = createResource<string>((resolve) => {
|
|
130
|
-
setTimeout(() => resolve("delayed"), 100);
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
expect(resource.loading).toBe(true);
|
|
134
|
-
|
|
135
|
-
vi.advanceTimersByTime(100);
|
|
136
|
-
|
|
137
|
-
expect(resource.state).toBe("ready");
|
|
138
|
-
expect(resource()).toBe("delayed");
|
|
139
|
-
|
|
140
|
-
vi.useRealTimers();
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
test("can wrap fetch-like async operations", async () => {
|
|
144
|
-
const mockFetch = vi.fn().mockResolvedValue({ data: "fetched" });
|
|
145
|
-
|
|
146
|
-
const [resource] = createResource<{ data: string }>((resolve, reject) => {
|
|
147
|
-
mockFetch()
|
|
148
|
-
.then(resolve)
|
|
149
|
-
.catch((e: Error) => reject(e.message));
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
// Wait for promise to resolve
|
|
153
|
-
await vi.waitFor(() => {
|
|
154
|
-
expect(resource.state).toBe("ready");
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
expect(resource()).toEqual({ data: "fetched" });
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
});
|
package/tests/router.test.ts
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect, beforeEach } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
routePage,
|
|
4
|
-
routePageTitled,
|
|
5
|
-
routePageFull,
|
|
6
|
-
createRouter,
|
|
7
|
-
routerNavigate,
|
|
8
|
-
routerReplace,
|
|
9
|
-
routerGetPath,
|
|
10
|
-
routerGetMatch,
|
|
11
|
-
routerGetBase,
|
|
12
|
-
type Routes,
|
|
13
|
-
type BrowserRouter,
|
|
14
|
-
} from "../src/index";
|
|
15
|
-
|
|
16
|
-
describe("Route definitions", () => {
|
|
17
|
-
test("routePage creates a page route", () => {
|
|
18
|
-
const route = routePage("/home", "HomePage");
|
|
19
|
-
expect(route).toBeDefined();
|
|
20
|
-
// MoonBit enum representation
|
|
21
|
-
expect((route as any).$tag).toBeDefined();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test("routePageTitled with title", () => {
|
|
25
|
-
const route = routePageTitled("/about", "AboutPage", "About Us");
|
|
26
|
-
expect(route).toBeDefined();
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test("routePageFull with title and meta", () => {
|
|
30
|
-
const route = routePageFull("/about", "AboutPage", "About Us", [
|
|
31
|
-
{ _0: "description", _1: "About our company" },
|
|
32
|
-
]);
|
|
33
|
-
expect(route).toBeDefined();
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
test("multiple page routes", () => {
|
|
37
|
-
const routes: Routes[] = [
|
|
38
|
-
routePage("/", "Home"),
|
|
39
|
-
routePage("/about", "About"),
|
|
40
|
-
routePage("/contact", "Contact"),
|
|
41
|
-
];
|
|
42
|
-
expect(routes.length).toBe(3);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
describe("BrowserRouter", () => {
|
|
47
|
-
let router: BrowserRouter;
|
|
48
|
-
|
|
49
|
-
beforeEach(() => {
|
|
50
|
-
// Reset location to root
|
|
51
|
-
window.history.replaceState(null, "", "/");
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
test("createRouter creates a router", () => {
|
|
55
|
-
const routes = [routePage("/", "Home"), routePage("/about", "About")];
|
|
56
|
-
router = createRouter(routes);
|
|
57
|
-
expect(router).toBeDefined();
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
test("createRouter with base path", () => {
|
|
61
|
-
const routes = [routePage("/", "Home")];
|
|
62
|
-
router = createRouter(routes, "/app");
|
|
63
|
-
expect(routerGetBase(router)).toBe("/app");
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test("routerGetPath returns current path", () => {
|
|
67
|
-
const routes = [routePage("/", "Home")];
|
|
68
|
-
router = createRouter(routes);
|
|
69
|
-
// Initial path should be "/"
|
|
70
|
-
const path = routerGetPath(router);
|
|
71
|
-
expect(typeof path).toBe("string");
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
test("routerNavigate changes path", () => {
|
|
75
|
-
const routes = [routePage("/", "Home"), routePage("/about", "About")];
|
|
76
|
-
router = createRouter(routes);
|
|
77
|
-
|
|
78
|
-
routerNavigate(router, "/about");
|
|
79
|
-
expect(routerGetPath(router)).toBe("/about");
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
test("routerReplace changes path without adding to history", () => {
|
|
83
|
-
const routes = [routePage("/", "Home"), routePage("/about", "About")];
|
|
84
|
-
router = createRouter(routes);
|
|
85
|
-
|
|
86
|
-
const historyLength = window.history.length;
|
|
87
|
-
routerReplace(router, "/about");
|
|
88
|
-
expect(routerGetPath(router)).toBe("/about");
|
|
89
|
-
// Replace should not add to history
|
|
90
|
-
expect(window.history.length).toBe(historyLength);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
test("routerGetMatch returns match for current route", () => {
|
|
94
|
-
const routes = [routePage("/", "Home"), routePage("/about", "About")];
|
|
95
|
-
router = createRouter(routes);
|
|
96
|
-
|
|
97
|
-
routerNavigate(router, "/about");
|
|
98
|
-
const match = routerGetMatch(router);
|
|
99
|
-
|
|
100
|
-
expect(match).toBeDefined();
|
|
101
|
-
if (match) {
|
|
102
|
-
expect(match.route.component).toBe("About");
|
|
103
|
-
expect(match.path).toBe("/about");
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
test("routerGetMatch returns undefined for unmatched route", () => {
|
|
108
|
-
const routes = [routePage("/", "Home")];
|
|
109
|
-
router = createRouter(routes);
|
|
110
|
-
|
|
111
|
-
routerNavigate(router, "/nonexistent");
|
|
112
|
-
const match = routerGetMatch(router);
|
|
113
|
-
// Should be undefined or match might still return something
|
|
114
|
-
// depending on implementation
|
|
115
|
-
expect(typeof match === "undefined" || match !== null).toBe(true);
|
|
116
|
-
});
|
|
117
|
-
});
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
/** @jsxImportSource ../src */
|
|
2
|
-
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
|
3
|
-
import "global-jsdom/register";
|
|
4
|
-
import {
|
|
5
|
-
createSignal,
|
|
6
|
-
onMount,
|
|
7
|
-
onCleanup,
|
|
8
|
-
render,
|
|
9
|
-
mount,
|
|
10
|
-
Show,
|
|
11
|
-
show,
|
|
12
|
-
} from "../src/index";
|
|
13
|
-
import type { JSX } from "../src/jsx-runtime";
|
|
14
|
-
|
|
15
|
-
const flushMicrotasks = () => new Promise<void>((resolve) => queueMicrotask(resolve));
|
|
16
|
-
const countLogs = (log: string[]) => {
|
|
17
|
-
const created = log.filter((item) => item.endsWith(" created")).length;
|
|
18
|
-
const mounted = log.filter((item) => item.endsWith(" mounted")).length;
|
|
19
|
-
const cleanups = log.filter((item) => item.endsWith(" cleanup")).length;
|
|
20
|
-
return { created, mounted, cleanups };
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const expectCounts = (
|
|
24
|
-
log: string[],
|
|
25
|
-
expected: { created: number; mounted: number; cleanups: number },
|
|
26
|
-
) => {
|
|
27
|
-
const { created, mounted, cleanups } = countLogs(log);
|
|
28
|
-
try {
|
|
29
|
-
expect(created).toBe(expected.created);
|
|
30
|
-
expect(mounted).toBe(expected.mounted);
|
|
31
|
-
expect(cleanups).toBe(expected.cleanups);
|
|
32
|
-
} catch (error) {
|
|
33
|
-
console.log({ counts: { created, mounted, cleanups }, log });
|
|
34
|
-
throw error;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
describe("Show initial mount behavior", () => {
|
|
39
|
-
let container: HTMLElement;
|
|
40
|
-
|
|
41
|
-
beforeEach(() => {
|
|
42
|
-
container = document.createElement("div");
|
|
43
|
-
document.body.appendChild(container);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
afterEach(() => {
|
|
47
|
-
container.remove();
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it("reproduces multiple instances with Show when=true on initial render", async () => {
|
|
51
|
-
const log: string[] = [];
|
|
52
|
-
let gId = 1;
|
|
53
|
-
|
|
54
|
-
function Child(): JSX.Element {
|
|
55
|
-
const id = gId++;
|
|
56
|
-
|
|
57
|
-
onMount(() => {
|
|
58
|
-
log.push(`${id} mounted`);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
onCleanup(() => {
|
|
62
|
-
log.push(`${id} cleanup`);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
log.push(`${id} created`);
|
|
66
|
-
|
|
67
|
-
return <p>I'm here</p>;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function Counter(): JSX.Element {
|
|
71
|
-
return (
|
|
72
|
-
<div>
|
|
73
|
-
<Show when={true}>{() => <Child />}</Show>
|
|
74
|
-
</div>
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
render(container, <Counter />);
|
|
79
|
-
|
|
80
|
-
await flushMicrotasks();
|
|
81
|
-
await flushMicrotasks();
|
|
82
|
-
await flushMicrotasks();
|
|
83
|
-
await flushMicrotasks();
|
|
84
|
-
|
|
85
|
-
expectCounts(log, { created: 1, mounted: 1, cleanups: 0 });
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it("does not create multiple instances without Show", async () => {
|
|
89
|
-
const log: string[] = [];
|
|
90
|
-
let gId = 1;
|
|
91
|
-
|
|
92
|
-
function Child(): JSX.Element {
|
|
93
|
-
const id = gId++;
|
|
94
|
-
|
|
95
|
-
onMount(() => {
|
|
96
|
-
log.push(`${id} mounted`);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
onCleanup(() => {
|
|
100
|
-
log.push(`${id} cleanup`);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
log.push(`${id} created`);
|
|
104
|
-
|
|
105
|
-
return <p>I'm here</p>;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function Counter(): JSX.Element {
|
|
109
|
-
return (
|
|
110
|
-
<div>
|
|
111
|
-
<Child />
|
|
112
|
-
</div>
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
render(container, <Counter />);
|
|
117
|
-
|
|
118
|
-
await flushMicrotasks();
|
|
119
|
-
await flushMicrotasks();
|
|
120
|
-
|
|
121
|
-
expectCounts(log, { created: 1, mounted: 1, cleanups: 0 });
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it("does not create multiple instances with Show when=true using mount", async () => {
|
|
125
|
-
const log: string[] = [];
|
|
126
|
-
let gId = 1;
|
|
127
|
-
|
|
128
|
-
function Child(): JSX.Element {
|
|
129
|
-
const id = gId++;
|
|
130
|
-
|
|
131
|
-
onMount(() => {
|
|
132
|
-
log.push(`${id} mounted`);
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
onCleanup(() => {
|
|
136
|
-
log.push(`${id} cleanup`);
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
log.push(`${id} created`);
|
|
140
|
-
|
|
141
|
-
return <p>I'm here</p>;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const node = Show({ when: true, children: () => <Child /> });
|
|
145
|
-
mount(container, node);
|
|
146
|
-
|
|
147
|
-
await flushMicrotasks();
|
|
148
|
-
await flushMicrotasks();
|
|
149
|
-
|
|
150
|
-
expectCounts(log, { created: 1, mounted: 1, cleanups: 0 });
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it("does not create multiple instances when render uses show() primitive", async () => {
|
|
154
|
-
const log: string[] = [];
|
|
155
|
-
let gId = 1;
|
|
156
|
-
const [visible] = createSignal(true);
|
|
157
|
-
|
|
158
|
-
function Child(): JSX.Element {
|
|
159
|
-
const id = gId++;
|
|
160
|
-
|
|
161
|
-
onMount(() => {
|
|
162
|
-
log.push(`${id} mounted`);
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
onCleanup(() => {
|
|
166
|
-
log.push(`${id} cleanup`);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
log.push(`${id} created`);
|
|
170
|
-
|
|
171
|
-
return <p>I'm here</p>;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
const node = show(visible, () => <Child />);
|
|
175
|
-
render(container, node);
|
|
176
|
-
|
|
177
|
-
await flushMicrotasks();
|
|
178
|
-
await flushMicrotasks();
|
|
179
|
-
|
|
180
|
-
expectCounts(log, { created: 1, mounted: 1, cleanups: 0 });
|
|
181
|
-
});
|
|
182
|
-
});
|