@alloy-js/core 0.23.0-dev.1 → 0.23.0-dev.11
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/CHANGELOG.md +0 -22
- package/dist/devtools/index.html +80 -0
- package/dist/src/binder.d.ts +2 -0
- package/dist/src/binder.d.ts.map +1 -1
- package/dist/src/binder.js +60 -12
- package/dist/src/binder.js.map +1 -1
- package/dist/src/components/AccessExpression.d.ts +78 -0
- package/dist/src/components/AccessExpression.d.ts.map +1 -0
- package/dist/src/components/AccessExpression.js +218 -0
- package/dist/src/components/AccessExpression.js.map +1 -0
- package/dist/src/components/AccessExpression.test.d.ts +2 -0
- package/dist/src/components/AccessExpression.test.d.ts.map +1 -0
- package/dist/src/components/AccessExpression.test.js +137 -0
- package/dist/src/components/AccessExpression.test.js.map +1 -0
- package/dist/src/components/AppendFile.d.ts.map +1 -1
- package/dist/src/components/AppendFile.js +14 -3
- package/dist/src/components/AppendFile.js.map +1 -1
- package/dist/src/components/Block.js +1 -1
- package/dist/src/components/Block.js.map +1 -1
- package/dist/src/components/Declaration.d.ts.map +1 -1
- package/dist/src/components/Declaration.js +2 -1
- package/dist/src/components/Declaration.js.map +1 -1
- package/dist/src/components/For.d.ts.map +1 -1
- package/dist/src/components/For.js +1 -1
- package/dist/src/components/For.js.map +1 -1
- package/dist/src/components/List.d.ts.map +1 -1
- package/dist/src/components/List.js +1 -1
- package/dist/src/components/List.js.map +1 -1
- package/dist/src/components/Prose.js +2 -2
- package/dist/src/components/Prose.js.map +1 -1
- package/dist/src/components/Scope.d.ts.map +1 -1
- package/dist/src/components/Scope.js +6 -1
- package/dist/src/components/Scope.js.map +1 -1
- package/dist/src/components/SourceDirectory.d.ts.map +1 -1
- package/dist/src/components/SourceDirectory.js +1 -2
- package/dist/src/components/SourceDirectory.js.map +1 -1
- package/dist/src/components/Switch.d.ts.map +1 -1
- package/dist/src/components/Switch.js +1 -1
- package/dist/src/components/Switch.js.map +1 -1
- package/dist/src/components/TemplateFile.d.ts.map +1 -1
- package/dist/src/components/TemplateFile.js +18 -3
- package/dist/src/components/TemplateFile.js.map +1 -1
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +1 -0
- package/dist/src/components/index.js.map +1 -1
- package/dist/src/content-slot.d.ts.map +1 -1
- package/dist/src/content-slot.js +7 -6
- package/dist/src/content-slot.js.map +1 -1
- package/dist/src/context.d.ts.map +1 -1
- package/dist/src/context.js +10 -3
- package/dist/src/context.js.map +1 -1
- package/dist/src/debug/cli.d.ts +6 -0
- package/dist/src/debug/cli.d.ts.map +1 -0
- package/dist/src/{debug.js → debug/cli.js} +79 -82
- package/dist/src/debug/cli.js.map +1 -0
- package/dist/src/debug/diagnostics.test.d.ts +2 -0
- package/dist/src/debug/diagnostics.test.d.ts.map +1 -0
- package/dist/src/debug/diagnostics.test.js +46 -0
- package/dist/src/debug/diagnostics.test.js.map +1 -0
- package/dist/src/debug/effects.d.ts +81 -0
- package/dist/src/debug/effects.d.ts.map +1 -0
- package/dist/src/debug/effects.js +358 -0
- package/dist/src/debug/effects.js.map +1 -0
- package/dist/src/debug/effects.test.d.ts +2 -0
- package/dist/src/debug/effects.test.d.ts.map +1 -0
- package/dist/src/debug/effects.test.js +256 -0
- package/dist/src/debug/effects.test.js.map +1 -0
- package/dist/src/debug/files.d.ts +14 -0
- package/dist/src/debug/files.d.ts.map +1 -0
- package/dist/src/debug/files.js +29 -0
- package/dist/src/debug/files.js.map +1 -0
- package/dist/src/debug/files.test.d.ts +2 -0
- package/dist/src/debug/files.test.d.ts.map +1 -0
- package/dist/src/debug/files.test.js +66 -0
- package/dist/src/debug/files.test.js.map +1 -0
- package/dist/src/debug/index.d.ts +63 -0
- package/dist/src/debug/index.d.ts.map +1 -0
- package/dist/src/debug/index.js +71 -0
- package/dist/src/debug/index.js.map +1 -0
- package/dist/src/debug/message-format.test.d.ts +2 -0
- package/dist/src/debug/message-format.test.d.ts.map +1 -0
- package/dist/src/debug/message-format.test.js +700 -0
- package/dist/src/debug/message-format.test.js.map +1 -0
- package/dist/src/debug/render-tree-orphans.test.d.ts +2 -0
- package/dist/src/debug/render-tree-orphans.test.d.ts.map +1 -0
- package/dist/src/debug/render-tree-orphans.test.js +297 -0
- package/dist/src/debug/render-tree-orphans.test.js.map +1 -0
- package/dist/src/debug/render.d.ts +57 -0
- package/dist/src/debug/render.d.ts.map +1 -0
- package/dist/src/debug/render.js +472 -0
- package/dist/src/debug/render.js.map +1 -0
- package/dist/src/debug/render.test.d.ts +2 -0
- package/dist/src/debug/render.test.d.ts.map +1 -0
- package/dist/src/debug/render.test.js +291 -0
- package/dist/src/debug/render.test.js.map +1 -0
- package/dist/src/debug/serialize.d.ts +9 -0
- package/dist/src/debug/serialize.d.ts.map +1 -0
- package/dist/src/debug/serialize.js +70 -0
- package/dist/src/debug/serialize.js.map +1 -0
- package/dist/src/debug/symbols.d.ts +16 -0
- package/dist/src/debug/symbols.d.ts.map +1 -0
- package/dist/src/debug/symbols.js +196 -0
- package/dist/src/debug/symbols.js.map +1 -0
- package/dist/src/debug/symbols.test.d.ts +2 -0
- package/dist/src/debug/symbols.test.d.ts.map +1 -0
- package/dist/src/debug/symbols.test.js +93 -0
- package/dist/src/debug/symbols.test.js.map +1 -0
- package/dist/src/debug/trace-writer.d.ts +55 -0
- package/dist/src/debug/trace-writer.d.ts.map +1 -0
- package/dist/src/debug/trace-writer.js +658 -0
- package/dist/src/debug/trace-writer.js.map +1 -0
- package/dist/src/debug/trace.d.ts +342 -0
- package/dist/src/debug/trace.d.ts.map +1 -0
- package/dist/src/debug/trace.js +446 -0
- package/dist/src/debug/trace.js.map +1 -0
- package/dist/src/devtools/devtools-protocol.d.ts +389 -0
- package/dist/src/devtools/devtools-protocol.d.ts.map +1 -0
- package/dist/src/devtools/devtools-protocol.js +2 -0
- package/dist/src/devtools/devtools-protocol.js.map +1 -0
- package/dist/src/devtools/devtools-server.browser.d.ts +23 -0
- package/dist/src/devtools/devtools-server.browser.d.ts.map +1 -0
- package/dist/src/devtools/devtools-server.browser.js +33 -0
- package/dist/src/devtools/devtools-server.browser.js.map +1 -0
- package/dist/src/devtools/devtools-server.d.ts +66 -0
- package/dist/src/devtools/devtools-server.d.ts.map +1 -0
- package/dist/src/devtools/devtools-server.js +444 -0
- package/dist/src/devtools/devtools-server.js.map +1 -0
- package/dist/src/devtools/devtools-transport.d.ts +23 -0
- package/dist/src/devtools/devtools-transport.d.ts.map +1 -0
- package/dist/src/devtools/devtools-transport.js +114 -0
- package/dist/src/devtools/devtools-transport.js.map +1 -0
- package/dist/src/devtools-entry.browser.d.ts +4 -0
- package/dist/src/devtools-entry.browser.d.ts.map +1 -0
- package/dist/src/devtools-entry.browser.js +2 -0
- package/dist/src/devtools-entry.browser.js.map +1 -0
- package/dist/src/devtools-entry.d.ts +4 -0
- package/dist/src/devtools-entry.d.ts.map +1 -0
- package/dist/src/devtools-entry.js +2 -0
- package/dist/src/devtools-entry.js.map +1 -0
- package/dist/src/diagnostics.d.ts +34 -0
- package/dist/src/diagnostics.d.ts.map +1 -0
- package/dist/src/diagnostics.js +89 -0
- package/dist/src/diagnostics.js.map +1 -0
- package/dist/src/index.d.ts +3 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/print-hook.d.ts +14 -0
- package/dist/src/print-hook.d.ts.map +1 -0
- package/dist/src/print-hook.js +10 -0
- package/dist/src/print-hook.js.map +1 -0
- package/dist/src/reactive-union-set.d.ts.map +1 -1
- package/dist/src/reactive-union-set.js +28 -3
- package/dist/src/reactive-union-set.js.map +1 -1
- package/dist/src/reactivity.d.ts +60 -7
- package/dist/src/reactivity.d.ts.map +1 -1
- package/dist/src/reactivity.js +308 -39
- package/dist/src/reactivity.js.map +1 -1
- package/dist/src/render-stack.d.ts +18 -1
- package/dist/src/render-stack.d.ts.map +1 -1
- package/dist/src/render-stack.js +61 -1
- package/dist/src/render-stack.js.map +1 -1
- package/dist/src/render.d.ts +8 -15
- package/dist/src/render.d.ts.map +1 -1
- package/dist/src/render.js +424 -109
- package/dist/src/render.js.map +1 -1
- package/dist/src/resource.d.ts.map +1 -1
- package/dist/src/resource.js +5 -0
- package/dist/src/resource.js.map +1 -1
- package/dist/src/scheduler.d.ts +13 -0
- package/dist/src/scheduler.d.ts.map +1 -1
- package/dist/src/scheduler.js +150 -13
- package/dist/src/scheduler.js.map +1 -1
- package/dist/src/symbols/basic-symbol.d.ts.map +1 -1
- package/dist/src/symbols/basic-symbol.js +6 -1
- package/dist/src/symbols/basic-symbol.js.map +1 -1
- package/dist/src/symbols/decl.d.ts.map +1 -1
- package/dist/src/symbols/decl.js +5 -1
- package/dist/src/symbols/decl.js.map +1 -1
- package/dist/src/symbols/output-scope.d.ts +2 -1
- package/dist/src/symbols/output-scope.d.ts.map +1 -1
- package/dist/src/symbols/output-scope.js +13 -8
- package/dist/src/symbols/output-scope.js.map +1 -1
- package/dist/src/symbols/output-symbol.d.ts +1 -0
- package/dist/src/symbols/output-symbol.d.ts.map +1 -1
- package/dist/src/symbols/output-symbol.js +25 -8
- package/dist/src/symbols/output-symbol.js.map +1 -1
- package/dist/src/symbols/symbol-flow.d.ts.map +1 -1
- package/dist/src/symbols/symbol-flow.js +24 -8
- package/dist/src/symbols/symbol-flow.js.map +1 -1
- package/dist/src/symbols/symbol-slot.d.ts.map +1 -1
- package/dist/src/symbols/symbol-slot.js +15 -0
- package/dist/src/symbols/symbol-slot.js.map +1 -1
- package/dist/src/symbols/symbol-slot.test.d.ts +2 -0
- package/dist/src/symbols/symbol-slot.test.d.ts.map +1 -0
- package/dist/src/symbols/symbol-slot.test.js +35 -0
- package/dist/src/symbols/symbol-slot.test.js.map +1 -0
- package/dist/src/symbols/symbol-table.d.ts.map +1 -1
- package/dist/src/symbols/symbol-table.js +6 -5
- package/dist/src/symbols/symbol-table.js.map +1 -1
- package/dist/src/trace.d.ts +2 -0
- package/dist/src/trace.d.ts.map +1 -0
- package/dist/src/trace.js +2 -0
- package/dist/src/trace.js.map +1 -0
- package/dist/src/tracer.d.ts +2 -228
- package/dist/src/tracer.d.ts.map +1 -1
- package/dist/src/tracer.js +5 -298
- package/dist/src/tracer.js.map +1 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +17 -9
- package/dist/src/utils.js.map +1 -1
- package/dist/test/components/append-file.test.d.ts.map +1 -1
- package/dist/test/components/append-file.test.js +18 -10
- package/dist/test/components/append-file.test.js.map +1 -1
- package/dist/test/components/template-file.test.d.ts.map +1 -1
- package/dist/test/components/template-file.test.js +6 -4
- package/dist/test/components/template-file.test.js.map +1 -1
- package/dist/test/lazy-isempty.test.d.ts +2 -0
- package/dist/test/lazy-isempty.test.d.ts.map +1 -0
- package/dist/test/lazy-isempty.test.js +89 -0
- package/dist/test/lazy-isempty.test.js.map +1 -0
- package/dist/test/reactive-union-set-disposers.test.d.ts +2 -0
- package/dist/test/reactive-union-set-disposers.test.d.ts.map +1 -0
- package/dist/test/reactive-union-set-disposers.test.js +98 -0
- package/dist/test/reactive-union-set-disposers.test.js.map +1 -0
- package/dist/test/reactivity/shallow-reactive.test.d.ts +2 -0
- package/dist/test/reactivity/shallow-reactive.test.d.ts.map +1 -0
- package/dist/test/reactivity/shallow-reactive.test.js +52 -0
- package/dist/test/reactivity/shallow-reactive.test.js.map +1 -0
- package/dist/test/rendering/basic.test.js +3 -0
- package/dist/test/rendering/basic.test.js.map +1 -1
- package/dist/test/rendering/print-render-stack.test.d.ts.map +1 -1
- package/dist/test/rendering/print-render-stack.test.js +91 -98
- package/dist/test/rendering/print-render-stack.test.js.map +1 -1
- package/dist/test/scheduler-extended.test.d.ts +2 -0
- package/dist/test/scheduler-extended.test.d.ts.map +1 -0
- package/dist/test/scheduler-extended.test.js +96 -0
- package/dist/test/scheduler-extended.test.js.map +1 -0
- package/dist/test/scheduler.test.d.ts +2 -0
- package/dist/test/scheduler.test.d.ts.map +1 -0
- package/dist/test/scheduler.test.js +46 -0
- package/dist/test/scheduler.test.js.map +1 -0
- package/dist/testing/create-test-wrapper.d.ts +1 -1
- package/dist/testing/create-test-wrapper.d.ts.map +1 -1
- package/dist/testing/create-test-wrapper.js +1 -1
- package/dist/testing/create-test-wrapper.js.map +1 -1
- package/dist/testing/devtools-utils.d.ts +35 -0
- package/dist/testing/devtools-utils.d.ts.map +1 -0
- package/dist/testing/devtools-utils.js +162 -0
- package/dist/testing/devtools-utils.js.map +1 -0
- package/dist/testing/extend-expect.d.ts.map +1 -1
- package/dist/testing/extend-expect.js +63 -1
- package/dist/testing/extend-expect.js.map +1 -1
- package/dist/testing/render.d.ts +2 -2
- package/dist/testing/render.d.ts.map +1 -1
- package/dist/testing/render.js +2 -2
- package/dist/testing/render.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +21 -7
- package/scripts/copy-devtools-ui.mjs +26 -0
- package/src/binder.ts +117 -53
- package/src/components/AccessExpression.test.tsx +132 -0
- package/src/components/AccessExpression.tsx +344 -0
- package/src/components/AppendFile.tsx +14 -9
- package/src/components/Block.tsx +1 -1
- package/src/components/Declaration.tsx +2 -1
- package/src/components/For.tsx +14 -10
- package/src/components/List.tsx +7 -4
- package/src/components/Prose.tsx +1 -1
- package/src/components/Scope.tsx +6 -1
- package/src/components/SourceDirectory.tsx +1 -2
- package/src/components/Switch.tsx +11 -7
- package/src/components/TemplateFile.tsx +18 -9
- package/src/components/index.tsx +1 -0
- package/src/content-slot.tsx +7 -7
- package/src/context.ts +17 -6
- package/src/{debug.ts → debug/cli.ts} +114 -125
- package/src/debug/diagnostics.test.tsx +56 -0
- package/src/debug/effects.test.tsx +301 -0
- package/src/debug/effects.ts +531 -0
- package/src/debug/files.test.tsx +76 -0
- package/src/debug/files.ts +40 -0
- package/src/debug/index.ts +132 -0
- package/src/debug/message-format.test.tsx +759 -0
- package/src/debug/render-tree-orphans.test.tsx +344 -0
- package/src/debug/render.test.tsx +357 -0
- package/src/debug/render.ts +698 -0
- package/src/debug/serialize.ts +85 -0
- package/src/debug/symbols.test.tsx +105 -0
- package/src/debug/symbols.ts +322 -0
- package/src/debug/trace-writer.ts +969 -0
- package/src/debug/trace.ts +309 -0
- package/src/devtools/devtools-protocol.ts +497 -0
- package/src/devtools/devtools-server.browser.ts +62 -0
- package/src/devtools/devtools-server.ts +468 -0
- package/src/devtools/devtools-transport.ts +154 -0
- package/src/devtools-entry.browser.ts +48 -0
- package/src/devtools-entry.ts +48 -0
- package/src/diagnostics.ts +150 -0
- package/src/index.ts +2 -7
- package/src/print-hook.ts +22 -0
- package/src/reactive-union-set.ts +85 -44
- package/src/reactivity.ts +396 -58
- package/src/render-stack.ts +73 -1
- package/src/render.ts +544 -161
- package/src/resource.ts +28 -19
- package/src/scheduler.ts +209 -14
- package/src/symbols/basic-symbol.ts +6 -1
- package/src/symbols/decl.ts +5 -1
- package/src/symbols/output-scope.ts +21 -13
- package/src/symbols/output-symbol.ts +34 -14
- package/src/symbols/symbol-flow.ts +76 -39
- package/src/symbols/symbol-slot.test.tsx +41 -0
- package/src/symbols/symbol-slot.tsx +47 -20
- package/src/symbols/symbol-table.ts +6 -10
- package/src/trace.ts +1 -0
- package/src/tracer.ts +13 -242
- package/src/utils.tsx +31 -21
- package/temp/api.json +5700 -3015
- package/test/components/append-file.test.tsx +36 -29
- package/test/components/template-file.test.tsx +11 -11
- package/test/lazy-isempty.test.tsx +106 -0
- package/test/reactive-union-set-disposers.test.tsx +112 -0
- package/test/reactivity/shallow-reactive.test.tsx +56 -0
- package/test/rendering/basic.test.tsx +4 -0
- package/test/rendering/print-render-stack.test.tsx +52 -43
- package/test/scheduler-extended.test.tsx +122 -0
- package/test/scheduler.test.tsx +50 -0
- package/testing/create-test-wrapper.tsx +1 -1
- package/testing/devtools-utils.ts +245 -0
- package/testing/extend-expect.ts +89 -0
- package/testing/render.ts +2 -2
- package/testing/vitest.d.ts +9 -0
- package/dist/src/debug.d.ts +0 -14
- package/dist/src/debug.d.ts.map +0 -1
- package/dist/src/debug.js.map +0 -1
|
@@ -3,7 +3,6 @@ import { tmpdir } from "os";
|
|
|
3
3
|
import { join } from "path";
|
|
4
4
|
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
5
5
|
import { AppendFile, AppendRegion } from "../../src/components/AppendFile.jsx";
|
|
6
|
-
import { render, renderAsync } from "../../src/render.js";
|
|
7
6
|
import "../../testing/extend-expect.js";
|
|
8
7
|
import { d } from "../../testing/render.js";
|
|
9
8
|
|
|
@@ -34,6 +33,7 @@ describe("AppendFile", () => {
|
|
|
34
33
|
|
|
35
34
|
await expect(result).toRenderToAsync("Initial content\nNew content");
|
|
36
35
|
});
|
|
36
|
+
|
|
37
37
|
it("should append content to end of file when no sigils present with no explicit append region", async () => {
|
|
38
38
|
// Create initial file content
|
|
39
39
|
writeFileSync(testFilePath, "Initial content", "utf-8");
|
|
@@ -148,30 +148,35 @@ describe("AppendFile", () => {
|
|
|
148
148
|
await expect(result).toRenderToAsync("Content\ndefault region");
|
|
149
149
|
});
|
|
150
150
|
|
|
151
|
-
it("should
|
|
151
|
+
it("should emit diagnostic when region is missing corresponding AppendRegion", async () => {
|
|
152
152
|
writeFileSync(testFilePath, "content", "utf-8");
|
|
153
153
|
|
|
154
|
-
expect(
|
|
155
|
-
|
|
156
|
-
<
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
154
|
+
await expect(
|
|
155
|
+
<AppendFile path={testFilePath} regions={["missing"]}>
|
|
156
|
+
<AppendRegion id="append">content</AppendRegion>
|
|
157
|
+
</AppendFile>,
|
|
158
|
+
).toHaveDiagnosticsAsync([
|
|
159
|
+
{
|
|
160
|
+
message:
|
|
161
|
+
'Region "missing" specified but no corresponding AppendRegion child found',
|
|
162
|
+
severity: "error",
|
|
163
|
+
},
|
|
164
|
+
]);
|
|
163
165
|
});
|
|
164
166
|
|
|
165
|
-
it("should
|
|
167
|
+
it("should emit diagnostic when AppendRegion has neither children nor content", async () => {
|
|
166
168
|
writeFileSync(testFilePath, "content", "utf-8");
|
|
167
169
|
|
|
168
|
-
expect(
|
|
169
|
-
|
|
170
|
-
<
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
170
|
+
await expect(
|
|
171
|
+
<AppendFile path={testFilePath}>
|
|
172
|
+
<AppendRegion id="append" />
|
|
173
|
+
</AppendFile>,
|
|
174
|
+
).toHaveDiagnosticsAsync([
|
|
175
|
+
{
|
|
176
|
+
message: 'AppendRegion "append" must have either children or content',
|
|
177
|
+
severity: "error",
|
|
178
|
+
},
|
|
179
|
+
]);
|
|
175
180
|
});
|
|
176
181
|
|
|
177
182
|
it("should throw error when region has missing start sigil", async () => {
|
|
@@ -196,7 +201,7 @@ describe("AppendFile", () => {
|
|
|
196
201
|
`);
|
|
197
202
|
});
|
|
198
203
|
|
|
199
|
-
it("should
|
|
204
|
+
it("should emit diagnostic when region has missing end sigil", async () => {
|
|
200
205
|
const contentWithOnlyStart = d`
|
|
201
206
|
Content
|
|
202
207
|
<!-- alloy-incomplete-start -->
|
|
@@ -204,15 +209,17 @@ describe("AppendFile", () => {
|
|
|
204
209
|
|
|
205
210
|
writeFileSync(testFilePath, contentWithOnlyStart, "utf-8");
|
|
206
211
|
|
|
207
|
-
await expect(
|
|
208
|
-
|
|
209
|
-
<
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
212
|
+
await expect(
|
|
213
|
+
<AppendFile path={testFilePath} regions={["incomplete"]}>
|
|
214
|
+
<AppendRegion id="incomplete">content</AppendRegion>
|
|
215
|
+
</AppendFile>,
|
|
216
|
+
).toHaveDiagnosticsAsync([
|
|
217
|
+
{
|
|
218
|
+
message:
|
|
219
|
+
'Region "incomplete" has start sigil but no corresponding end sigil',
|
|
220
|
+
severity: "error",
|
|
221
|
+
},
|
|
222
|
+
]);
|
|
216
223
|
});
|
|
217
224
|
|
|
218
225
|
it("should handle complex nested content", async () => {
|
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
TemplateFile,
|
|
7
7
|
TemplateVariable,
|
|
8
8
|
} from "../../src/components/TemplateFile.jsx";
|
|
9
|
-
import { renderAsync } from "../../src/render.js";
|
|
10
9
|
import "../../testing/extend-expect.js";
|
|
11
10
|
import { d } from "../../testing/render.js";
|
|
12
11
|
|
|
@@ -82,21 +81,22 @@ describe("TemplateFile", () => {
|
|
|
82
81
|
await expect(result).toRenderToAsync("Hello Bob!");
|
|
83
82
|
});
|
|
84
83
|
|
|
85
|
-
it("should
|
|
84
|
+
it("should emit diagnostic for missing template variables", async () => {
|
|
86
85
|
const templatePath = join(tmpdir(), "test-missing-var-template.txt");
|
|
87
86
|
const templateContent = "Hello {{ name }}! Your age is {{ age }}.";
|
|
88
87
|
writeFileSync(templatePath, templateContent);
|
|
89
88
|
|
|
90
89
|
await expect(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
90
|
+
<TemplateFile src={templatePath} path="output.txt">
|
|
91
|
+
<TemplateVariable name="name" value="Charlie" />
|
|
92
|
+
</TemplateFile>,
|
|
93
|
+
).toHaveDiagnosticsAsync([
|
|
94
|
+
{
|
|
95
|
+
message:
|
|
96
|
+
'Template variable "age" not found in TemplateVariable children',
|
|
97
|
+
severity: "error",
|
|
98
|
+
},
|
|
99
|
+
]);
|
|
100
100
|
});
|
|
101
101
|
|
|
102
102
|
it("should handle template with no variables", async () => {
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { ref } from "@vue/reactivity";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { Show } from "../src/components/Show.jsx";
|
|
4
|
+
import { createContentSlot } from "../src/content-slot.jsx";
|
|
5
|
+
import { Context, ensureIsEmpty, getContext } from "../src/reactivity.js";
|
|
6
|
+
import { printTree, renderTree } from "../src/render.js";
|
|
7
|
+
import "../testing/extend-expect.js";
|
|
8
|
+
|
|
9
|
+
describe("lazy isEmpty / _lastEmpty", () => {
|
|
10
|
+
it("context starts without isEmpty ref allocated", () => {
|
|
11
|
+
let ctx: Context | null = null;
|
|
12
|
+
|
|
13
|
+
function Capture() {
|
|
14
|
+
ctx = getContext()!;
|
|
15
|
+
return "content";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
renderTree(<Capture />);
|
|
19
|
+
|
|
20
|
+
// The isEmpty ref should NOT be allocated unless someone observes it.
|
|
21
|
+
expect(ctx).not.toBeNull();
|
|
22
|
+
expect(ctx!.isEmpty).toBeUndefined();
|
|
23
|
+
expect(ctx!._lastEmpty).toBe(false);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("ensureIsEmpty lazily allocates the isEmpty ref", () => {
|
|
27
|
+
let ctx: Context | null = null;
|
|
28
|
+
|
|
29
|
+
function Capture() {
|
|
30
|
+
ctx = getContext()!;
|
|
31
|
+
return "content";
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
renderTree(<Capture />);
|
|
35
|
+
|
|
36
|
+
expect(ctx!.isEmpty).toBeUndefined();
|
|
37
|
+
const isEmptyRef = ensureIsEmpty(ctx!);
|
|
38
|
+
expect(ctx!.isEmpty).toBeDefined();
|
|
39
|
+
expect(isEmptyRef).toBe(ctx!.isEmpty);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("_lastEmpty is true for empty component, false for non-empty", () => {
|
|
43
|
+
let emptyCtx: Context | null = null;
|
|
44
|
+
let fullCtx: Context | null = null;
|
|
45
|
+
|
|
46
|
+
function EmptyCapture() {
|
|
47
|
+
emptyCtx = getContext()!;
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function FullCapture() {
|
|
52
|
+
fullCtx = getContext()!;
|
|
53
|
+
return "has content";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
renderTree(
|
|
57
|
+
<>
|
|
58
|
+
<EmptyCapture />
|
|
59
|
+
<FullCapture />
|
|
60
|
+
</>,
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
expect(emptyCtx!._lastEmpty).toBe(true);
|
|
64
|
+
expect(fullCtx!._lastEmpty).toBe(false);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("ContentSlot triggers ensureIsEmpty and tracks reactively", () => {
|
|
68
|
+
const ContentSlot = createContentSlot();
|
|
69
|
+
const showContent = ref(false);
|
|
70
|
+
|
|
71
|
+
const tree = renderTree(
|
|
72
|
+
<>
|
|
73
|
+
{ContentSlot.isEmpty && "empty"}
|
|
74
|
+
<ContentSlot>
|
|
75
|
+
<Show when={showContent.value}>content</Show>
|
|
76
|
+
</ContentSlot>
|
|
77
|
+
</>,
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
expect(printTree(tree)).toBe("empty");
|
|
81
|
+
|
|
82
|
+
showContent.value = true;
|
|
83
|
+
expect(printTree(tree)).toBe("content");
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("propagates empty state up through parent contexts", () => {
|
|
87
|
+
const OuterSlot = createContentSlot();
|
|
88
|
+
const showContent = ref(false);
|
|
89
|
+
|
|
90
|
+
const tree = renderTree(
|
|
91
|
+
<>
|
|
92
|
+
{OuterSlot.isEmpty && "outer-empty"}
|
|
93
|
+
<OuterSlot>
|
|
94
|
+
<Show when={showContent.value}>content</Show>
|
|
95
|
+
</OuterSlot>
|
|
96
|
+
</>,
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
// Outer should be empty initially.
|
|
100
|
+
expect(printTree(tree)).toBe("outer-empty");
|
|
101
|
+
|
|
102
|
+
// Show content — outer should become non-empty.
|
|
103
|
+
showContent.value = true;
|
|
104
|
+
expect(printTree(tree)).toBe("content");
|
|
105
|
+
});
|
|
106
|
+
});
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { reactive } from "@vue/reactivity";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { ReactiveUnionSet } from "../src/reactive-union-set.js";
|
|
4
|
+
import { effect } from "../src/reactivity.js";
|
|
5
|
+
import { flushJobs } from "../src/scheduler.js";
|
|
6
|
+
|
|
7
|
+
describe("ReactiveUnionSet: per-item disposers via addSubset", () => {
|
|
8
|
+
it("calls onDelete when item is removed from subset", () => {
|
|
9
|
+
const parentSet = new ReactiveUnionSet<string>();
|
|
10
|
+
const subset = reactive(new Set<string>());
|
|
11
|
+
const deleted: string[] = [];
|
|
12
|
+
|
|
13
|
+
parentSet.addSubset(subset, {
|
|
14
|
+
onDelete(value) {
|
|
15
|
+
deleted.push(value);
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
subset.add("a");
|
|
20
|
+
subset.add("b");
|
|
21
|
+
flushJobs();
|
|
22
|
+
expect(parentSet.has("a")).toBe(true);
|
|
23
|
+
expect(parentSet.has("b")).toBe(true);
|
|
24
|
+
|
|
25
|
+
subset.delete("a");
|
|
26
|
+
flushJobs();
|
|
27
|
+
expect(parentSet.has("a")).toBe(false);
|
|
28
|
+
expect(deleted).toContain("a");
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("calls onDelete for all items when subset is cleared", () => {
|
|
32
|
+
const parentSet = new ReactiveUnionSet<string>();
|
|
33
|
+
const subset = reactive(new Set<string>());
|
|
34
|
+
const deleted: string[] = [];
|
|
35
|
+
|
|
36
|
+
parentSet.addSubset(subset, {
|
|
37
|
+
onDelete(value) {
|
|
38
|
+
deleted.push(value);
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
subset.add("a");
|
|
43
|
+
subset.add("b");
|
|
44
|
+
subset.add("c");
|
|
45
|
+
flushJobs();
|
|
46
|
+
expect(parentSet.size).toBe(3);
|
|
47
|
+
|
|
48
|
+
subset.clear();
|
|
49
|
+
flushJobs();
|
|
50
|
+
expect(parentSet.size).toBe(0);
|
|
51
|
+
expect(deleted.sort()).toEqual(["a", "b", "c"]);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("disposes root scopes created by onAdd when item is removed", () => {
|
|
55
|
+
const parentSet = new ReactiveUnionSet<string>();
|
|
56
|
+
const subset = reactive(new Set<string>());
|
|
57
|
+
let disposeCount = 0;
|
|
58
|
+
|
|
59
|
+
// Use the constructor-level onAdd so items are still added to the set,
|
|
60
|
+
// plus per-subset onAdd with root scope tracking.
|
|
61
|
+
parentSet.addSubset(subset, {
|
|
62
|
+
onAdd(value) {
|
|
63
|
+
// The onAdd in addSubset wraps in root() internally.
|
|
64
|
+
// Side-effects created here are cleaned up when the item is removed.
|
|
65
|
+
effect(() => {
|
|
66
|
+
void value; // track nothing real, just proving the effect exists
|
|
67
|
+
});
|
|
68
|
+
return value;
|
|
69
|
+
},
|
|
70
|
+
onDelete() {
|
|
71
|
+
disposeCount++;
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
subset.add("x");
|
|
76
|
+
flushJobs();
|
|
77
|
+
|
|
78
|
+
// Remove item — root scope (and its effects) should be disposed.
|
|
79
|
+
subset.delete("x");
|
|
80
|
+
flushJobs();
|
|
81
|
+
expect(disposeCount).toBe(1);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("re-adding after delete triggers fresh onAdd", () => {
|
|
85
|
+
const parentSet = new ReactiveUnionSet<string>();
|
|
86
|
+
const subset = reactive(new Set<string>());
|
|
87
|
+
let addCount = 0;
|
|
88
|
+
const deleted: string[] = [];
|
|
89
|
+
|
|
90
|
+
parentSet.addSubset(subset, {
|
|
91
|
+
onAdd(value) {
|
|
92
|
+
addCount++;
|
|
93
|
+
return value;
|
|
94
|
+
},
|
|
95
|
+
onDelete(value) {
|
|
96
|
+
deleted.push(value);
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
subset.add("a");
|
|
101
|
+
flushJobs();
|
|
102
|
+
expect(addCount).toBe(1);
|
|
103
|
+
|
|
104
|
+
subset.delete("a");
|
|
105
|
+
flushJobs();
|
|
106
|
+
expect(deleted).toEqual(["a"]);
|
|
107
|
+
|
|
108
|
+
subset.add("a");
|
|
109
|
+
flushJobs();
|
|
110
|
+
expect(addCount).toBe(2);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
getReactiveCreationLocation,
|
|
4
|
+
shallowReactive,
|
|
5
|
+
} from "../../src/reactivity.js";
|
|
6
|
+
|
|
7
|
+
describe("shallowReactive creation location", () => {
|
|
8
|
+
let origDebug: string | undefined;
|
|
9
|
+
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
origDebug = process.env.ALLOY_DEBUG;
|
|
12
|
+
process.env.ALLOY_DEBUG = "1";
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
if (origDebug === undefined) {
|
|
17
|
+
delete process.env.ALLOY_DEBUG;
|
|
18
|
+
} else {
|
|
19
|
+
process.env.ALLOY_DEBUG = origDebug;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("stores creation location keyed by raw target when debug enabled", () => {
|
|
24
|
+
const raw = { x: 1 };
|
|
25
|
+
shallowReactive(raw);
|
|
26
|
+
|
|
27
|
+
const location = getReactiveCreationLocation(raw);
|
|
28
|
+
// When ALLOY_DEBUG is set, captureSourceLocation should return something.
|
|
29
|
+
expect(location).toBeDefined();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("does not store location when debug is disabled", () => {
|
|
33
|
+
delete process.env.ALLOY_DEBUG;
|
|
34
|
+
const raw = { y: 2 };
|
|
35
|
+
shallowReactive(raw);
|
|
36
|
+
|
|
37
|
+
const location = getReactiveCreationLocation(raw);
|
|
38
|
+
expect(location).toBeUndefined();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("location is keyed by raw target, not proxy", () => {
|
|
42
|
+
const raw = { z: 3 };
|
|
43
|
+
const proxy = shallowReactive(raw);
|
|
44
|
+
|
|
45
|
+
// Proxy and raw are different objects.
|
|
46
|
+
expect(proxy).not.toBe(raw);
|
|
47
|
+
|
|
48
|
+
// Location should be on the raw target.
|
|
49
|
+
const location = getReactiveCreationLocation(raw);
|
|
50
|
+
expect(location).toBeDefined();
|
|
51
|
+
|
|
52
|
+
// The proxy itself should NOT have a location stored (WeakMap keyed by raw).
|
|
53
|
+
// Note: Vue may unwrap the proxy to raw internally, but our code explicitly
|
|
54
|
+
// stores on `target` (the raw object passed to shallowReactive).
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Output,
|
|
3
|
+
SourceDirectory,
|
|
4
|
+
SourceFile,
|
|
5
|
+
renderAsync,
|
|
6
|
+
} from "@alloy-js/core";
|
|
2
7
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
8
|
+
import WebSocket from "ws";
|
|
3
9
|
import { createNamedContext } from "../../src/context.js";
|
|
10
|
+
import {
|
|
11
|
+
enableDevtools,
|
|
12
|
+
resetDevtoolsServerForTests,
|
|
13
|
+
} from "../../src/devtools/devtools-server.js";
|
|
4
14
|
import { clearRenderStack } from "../../src/render-stack.js";
|
|
5
|
-
import { renderTree } from "../../src/render.js";
|
|
6
15
|
import "../../testing/extend-expect.js";
|
|
7
16
|
|
|
8
17
|
// Strip ANSI escape codes from a string for consistent testing across environments
|
|
@@ -21,27 +30,29 @@ function expectErrorContaining(
|
|
|
21
30
|
}
|
|
22
31
|
|
|
23
32
|
describe("printRenderStack", () => {
|
|
24
|
-
let
|
|
25
|
-
|
|
26
|
-
beforeEach(() => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
33
|
+
let socket: WebSocket | undefined;
|
|
34
|
+
|
|
35
|
+
beforeEach(async () => {
|
|
36
|
+
const server = await enableDevtools({ port: 0 });
|
|
37
|
+
socket = new WebSocket(`ws://127.0.0.1:${server.port}`);
|
|
38
|
+
await new Promise<void>((resolve, reject) => {
|
|
39
|
+
socket?.once("open", resolve);
|
|
40
|
+
socket?.once("error", reject);
|
|
41
|
+
});
|
|
30
42
|
});
|
|
31
43
|
|
|
32
|
-
afterEach(() => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
} else {
|
|
37
|
-
process.env.ALLOY_DEBUG = originalEnv;
|
|
44
|
+
afterEach(async () => {
|
|
45
|
+
if (socket) {
|
|
46
|
+
socket.close();
|
|
47
|
+
socket = undefined;
|
|
38
48
|
}
|
|
49
|
+
await resetDevtoolsServerForTests();
|
|
39
50
|
|
|
40
51
|
// Clear render stack to prevent state leakage between tests
|
|
41
52
|
clearRenderStack();
|
|
42
53
|
});
|
|
43
54
|
|
|
44
|
-
it("prints the current file when an error occurs", () => {
|
|
55
|
+
it("prints the current file when an error occurs", async () => {
|
|
45
56
|
const consoleErrorSpy = vi.spyOn(console, "error");
|
|
46
57
|
|
|
47
58
|
function ThrowingComponent() {
|
|
@@ -52,15 +63,15 @@ describe("printRenderStack", () => {
|
|
|
52
63
|
return <ThrowingComponent />;
|
|
53
64
|
}
|
|
54
65
|
|
|
55
|
-
expect(
|
|
56
|
-
|
|
66
|
+
await expect(
|
|
67
|
+
renderAsync(
|
|
57
68
|
<Output>
|
|
58
69
|
<SourceFile path="test.ts" filetype="typescript">
|
|
59
70
|
<ParentComponent />
|
|
60
71
|
</SourceFile>
|
|
61
72
|
</Output>,
|
|
62
|
-
)
|
|
63
|
-
|
|
73
|
+
),
|
|
74
|
+
).rejects.toThrow("Test error");
|
|
64
75
|
|
|
65
76
|
// Check that console.error was called with file path
|
|
66
77
|
expectErrorContaining(consoleErrorSpy, "Error rendering in file test.ts");
|
|
@@ -70,15 +81,15 @@ describe("printRenderStack", () => {
|
|
|
70
81
|
consoleErrorSpy.mockRestore();
|
|
71
82
|
});
|
|
72
83
|
|
|
73
|
-
it("prints joined path from nested directories", () => {
|
|
84
|
+
it("prints joined path from nested directories", async () => {
|
|
74
85
|
const consoleErrorSpy = vi.spyOn(console, "error");
|
|
75
86
|
|
|
76
87
|
function ThrowingComponent() {
|
|
77
88
|
throw new Error("Nested error");
|
|
78
89
|
}
|
|
79
90
|
|
|
80
|
-
expect(
|
|
81
|
-
|
|
91
|
+
await expect(
|
|
92
|
+
renderAsync(
|
|
82
93
|
<Output>
|
|
83
94
|
<SourceDirectory path="dir1">
|
|
84
95
|
<SourceDirectory path="dir2">
|
|
@@ -88,8 +99,8 @@ describe("printRenderStack", () => {
|
|
|
88
99
|
</SourceDirectory>
|
|
89
100
|
</SourceDirectory>
|
|
90
101
|
</Output>,
|
|
91
|
-
)
|
|
92
|
-
|
|
102
|
+
),
|
|
103
|
+
).rejects.toThrow("Nested error");
|
|
93
104
|
|
|
94
105
|
// Should show the joined path of all directories
|
|
95
106
|
expectErrorContaining(
|
|
@@ -100,7 +111,7 @@ describe("printRenderStack", () => {
|
|
|
100
111
|
consoleErrorSpy.mockRestore();
|
|
101
112
|
});
|
|
102
113
|
|
|
103
|
-
it("works when no file context is present", () => {
|
|
114
|
+
it("works when no file context is present", async () => {
|
|
104
115
|
const consoleErrorSpy = vi.spyOn(console, "error");
|
|
105
116
|
|
|
106
117
|
function ThrowingComponent() {
|
|
@@ -110,13 +121,13 @@ describe("printRenderStack", () => {
|
|
|
110
121
|
// Track the number of calls before our test
|
|
111
122
|
const callsBefore = consoleErrorSpy.mock.calls.length;
|
|
112
123
|
|
|
113
|
-
expect(
|
|
114
|
-
|
|
124
|
+
await expect(
|
|
125
|
+
renderAsync(
|
|
115
126
|
<Output>
|
|
116
127
|
<ThrowingComponent />
|
|
117
128
|
</Output>,
|
|
118
|
-
)
|
|
119
|
-
|
|
129
|
+
),
|
|
130
|
+
).rejects.toThrow("No file context error");
|
|
120
131
|
|
|
121
132
|
// Get only the calls from THIS test (after callsBefore)
|
|
122
133
|
const callsFromThisTest = consoleErrorSpy.mock.calls.slice(callsBefore);
|
|
@@ -135,7 +146,7 @@ describe("printRenderStack", () => {
|
|
|
135
146
|
consoleErrorSpy.mockRestore();
|
|
136
147
|
});
|
|
137
148
|
|
|
138
|
-
it("includes component stack with props", () => {
|
|
149
|
+
it("includes component stack with props", async () => {
|
|
139
150
|
const consoleErrorSpy = vi.spyOn(console, "error");
|
|
140
151
|
|
|
141
152
|
function ThrowingComponent(props: { message: string; count: number }) {
|
|
@@ -146,15 +157,15 @@ describe("printRenderStack", () => {
|
|
|
146
157
|
return <ThrowingComponent message={props.value} count={42} />;
|
|
147
158
|
}
|
|
148
159
|
|
|
149
|
-
expect(
|
|
150
|
-
|
|
160
|
+
await expect(
|
|
161
|
+
renderAsync(
|
|
151
162
|
<Output>
|
|
152
163
|
<SourceFile path="props-test.ts" filetype="typescript">
|
|
153
164
|
<WrapperComponent value="test" />
|
|
154
165
|
</SourceFile>
|
|
155
166
|
</Output>,
|
|
156
|
-
)
|
|
157
|
-
|
|
167
|
+
),
|
|
168
|
+
).rejects.toThrow("Component error");
|
|
158
169
|
|
|
159
170
|
expectErrorContaining(
|
|
160
171
|
consoleErrorSpy,
|
|
@@ -168,7 +179,7 @@ describe("printRenderStack", () => {
|
|
|
168
179
|
consoleErrorSpy.mockRestore();
|
|
169
180
|
});
|
|
170
181
|
|
|
171
|
-
it("prints 'Error rendering:' when no file or directory context is present", () => {
|
|
182
|
+
it("prints 'Error rendering:' when no file or directory context is present", async () => {
|
|
172
183
|
const consoleErrorSpy = vi.spyOn(console, "error");
|
|
173
184
|
|
|
174
185
|
function ThrowingComponent() {
|
|
@@ -179,9 +190,7 @@ describe("printRenderStack", () => {
|
|
|
179
190
|
const callsBefore = consoleErrorSpy.mock.calls.length;
|
|
180
191
|
|
|
181
192
|
// Don't use Output wrapper to avoid SourceDirectory context
|
|
182
|
-
expect(()
|
|
183
|
-
renderTree(<ThrowingComponent />);
|
|
184
|
-
}).toThrow();
|
|
193
|
+
await expect(renderAsync(<ThrowingComponent />)).rejects.toThrow();
|
|
185
194
|
|
|
186
195
|
// Get only the calls from THIS test (after callsBefore)
|
|
187
196
|
const callsFromThisTest = consoleErrorSpy.mock.calls.slice(callsBefore);
|
|
@@ -205,7 +214,7 @@ describe("printRenderStack", () => {
|
|
|
205
214
|
consoleErrorSpy.mockRestore();
|
|
206
215
|
});
|
|
207
216
|
|
|
208
|
-
it("shows context name for named context providers", () => {
|
|
217
|
+
it("shows context name for named context providers", async () => {
|
|
209
218
|
const consoleErrorSpy = vi.spyOn(console, "error");
|
|
210
219
|
|
|
211
220
|
const MyContext = createNamedContext<string>("MyContext");
|
|
@@ -214,8 +223,8 @@ describe("printRenderStack", () => {
|
|
|
214
223
|
throw new Error("Context error");
|
|
215
224
|
}
|
|
216
225
|
|
|
217
|
-
expect(
|
|
218
|
-
|
|
226
|
+
await expect(
|
|
227
|
+
renderAsync(
|
|
219
228
|
<Output>
|
|
220
229
|
<SourceFile path="context-test.ts" filetype="typescript">
|
|
221
230
|
<MyContext.Provider value="test-value">
|
|
@@ -223,8 +232,8 @@ describe("printRenderStack", () => {
|
|
|
223
232
|
</MyContext.Provider>
|
|
224
233
|
</SourceFile>
|
|
225
234
|
</Output>,
|
|
226
|
-
)
|
|
227
|
-
|
|
235
|
+
),
|
|
236
|
+
).rejects.toThrow("Context error");
|
|
228
237
|
|
|
229
238
|
// Check that the named context provider is shown as a separate component
|
|
230
239
|
expectErrorContaining(consoleErrorSpy, "at MyContext");
|