@alloy-js/core 0.24.0-dev.6 → 0.24.0-dev.7
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/dev/src/components/AccessExpression.test.js +30 -38
- package/dist/dev/src/components/AccessExpression.test.js.map +1 -1
- package/dist/dev/src/content-slot.test.js +16 -18
- package/dist/dev/src/content-slot.test.js.map +1 -1
- package/dist/dev/src/symbols/symbol-slot.test.js +4 -4
- package/dist/dev/src/symbols/symbol-slot.test.js.map +1 -1
- package/dist/dev/test/children.test.js +9 -11
- package/dist/dev/test/children.test.js.map +1 -1
- package/dist/dev/test/components/append-file.test.js +26 -27
- package/dist/dev/test/components/append-file.test.js.map +1 -1
- package/dist/dev/test/components/block.test.js +9 -11
- package/dist/dev/test/components/block.test.js.map +1 -1
- package/dist/dev/test/components/copy-file.test.js +6 -7
- package/dist/dev/test/components/copy-file.test.js.map +1 -1
- package/dist/dev/test/components/declaration.test.js +2 -2
- package/dist/dev/test/components/declaration.test.js.map +1 -1
- package/dist/dev/test/components/list.test.js +41 -43
- package/dist/dev/test/components/list.test.js.map +1 -1
- package/dist/dev/test/components/prose.test.js +4 -5
- package/dist/dev/test/components/prose.test.js.map +1 -1
- package/dist/dev/test/components/reference-or-content.test.js +32 -33
- package/dist/dev/test/components/reference-or-content.test.js.map +1 -1
- package/dist/dev/test/components/source-file.test.js +8 -7
- package/dist/dev/test/components/source-file.test.js.map +1 -1
- package/dist/dev/test/components/template-file.test.js +16 -17
- package/dist/dev/test/components/template-file.test.js.map +1 -1
- package/dist/dev/test/components/update-file.test.js +10 -11
- package/dist/dev/test/components/update-file.test.js.map +1 -1
- package/dist/dev/test/components/wrap.test.js +6 -8
- package/dist/dev/test/components/wrap.test.js.map +1 -1
- package/dist/dev/test/control-flow/for.test.js +58 -42
- package/dist/dev/test/control-flow/for.test.js.map +1 -1
- package/dist/dev/test/control-flow/match.test.js +15 -17
- package/dist/dev/test/control-flow/match.test.js.map +1 -1
- package/dist/dev/test/control-flow/show.test.js +5 -8
- package/dist/dev/test/control-flow/show.test.js.map +1 -1
- package/dist/dev/test/lazy-isempty.test.js +24 -26
- package/dist/dev/test/lazy-isempty.test.js.map +1 -1
- package/dist/dev/test/name-policy.test.js +2 -3
- package/dist/dev/test/name-policy.test.js.map +1 -1
- package/dist/dev/test/reactivity/circular-reactives.test.js +9 -9
- package/dist/dev/test/reactivity/circular-reactives.test.js.map +1 -1
- package/dist/dev/test/reactivity/cleanup.test.js +5 -6
- package/dist/dev/test/reactivity/cleanup.test.js.map +1 -1
- package/dist/dev/test/reactivity/ref-rendering.test.js +15 -15
- package/dist/dev/test/reactivity/ref-rendering.test.js.map +1 -1
- package/dist/dev/test/reactivity/test.test.js +18 -18
- package/dist/dev/test/reactivity/test.test.js.map +1 -1
- package/dist/dev/test/rendering/basic.test.js +18 -19
- package/dist/dev/test/rendering/basic.test.js.map +1 -1
- package/dist/dev/test/rendering/code.test.js +2 -3
- package/dist/dev/test/rendering/code.test.js.map +1 -1
- package/dist/dev/test/rendering/formatting.test.js +115 -121
- package/dist/dev/test/rendering/formatting.test.js.map +1 -1
- package/dist/dev/test/rendering/indent.test.js +23 -24
- package/dist/dev/test/rendering/indent.test.js.map +1 -1
- package/dist/dev/test/rendering/memoization.test.js +4 -5
- package/dist/dev/test/rendering/memoization.test.js.map +1 -1
- package/dist/dev/test/rendering/print-render-stack.test.js +20 -21
- package/dist/dev/test/rendering/print-render-stack.test.js.map +1 -1
- package/dist/dev/test/rendering/refkeys.test.js +1 -2
- package/dist/dev/test/rendering/refkeys.test.js.map +1 -1
- package/dist/dev/test/stc.test.js +0 -1
- package/dist/dev/test/stc.test.js.map +1 -1
- package/dist/dev/test/utils.test.js +34 -33
- package/dist/dev/test/utils.test.js.map +1 -1
- package/dist/dev/test/vitest.setup.js +2 -0
- package/dist/dev/test/vitest.setup.js.map +1 -0
- package/dist/dev/testing/extend-expect.js +23 -1
- package/dist/dev/testing/extend-expect.js.map +1 -1
- package/dist/src/components/AccessExpression.test.d.ts +1 -1
- package/dist/src/components/AccessExpression.test.d.ts.map +1 -1
- package/dist/src/components/AccessExpression.test.js +5 -13
- package/dist/src/components/AccessExpression.test.js.map +1 -1
- package/dist/src/content-slot.test.d.ts +1 -1
- package/dist/src/content-slot.test.d.ts.map +1 -1
- package/dist/src/content-slot.test.js +8 -10
- package/dist/src/content-slot.test.js.map +1 -1
- package/dist/src/symbols/symbol-slot.test.js +4 -4
- package/dist/src/symbols/symbol-slot.test.js.map +1 -1
- package/dist/test/children.test.js +5 -7
- package/dist/test/children.test.js.map +1 -1
- package/dist/test/components/append-file.test.d.ts +1 -1
- package/dist/test/components/append-file.test.d.ts.map +1 -1
- package/dist/test/components/append-file.test.js +0 -1
- package/dist/test/components/append-file.test.js.map +1 -1
- package/dist/test/components/block.test.d.ts +1 -1
- package/dist/test/components/block.test.d.ts.map +1 -1
- package/dist/test/components/block.test.js +4 -6
- package/dist/test/components/block.test.js.map +1 -1
- package/dist/test/components/copy-file.test.d.ts +1 -1
- package/dist/test/components/copy-file.test.d.ts.map +1 -1
- package/dist/test/components/copy-file.test.js +0 -1
- package/dist/test/components/copy-file.test.js.map +1 -1
- package/dist/test/components/declaration.test.js +2 -2
- package/dist/test/components/declaration.test.js.map +1 -1
- package/dist/test/components/list.test.d.ts +1 -1
- package/dist/test/components/list.test.d.ts.map +1 -1
- package/dist/test/components/list.test.js +20 -22
- package/dist/test/components/list.test.js.map +1 -1
- package/dist/test/components/prose.test.d.ts +1 -1
- package/dist/test/components/prose.test.d.ts.map +1 -1
- package/dist/test/components/prose.test.js +0 -1
- package/dist/test/components/prose.test.js.map +1 -1
- package/dist/test/components/reference-or-content.test.js +8 -9
- package/dist/test/components/reference-or-content.test.js.map +1 -1
- package/dist/test/components/source-file.test.d.ts +1 -1
- package/dist/test/components/source-file.test.d.ts.map +1 -1
- package/dist/test/components/source-file.test.js +5 -4
- package/dist/test/components/source-file.test.js.map +1 -1
- package/dist/test/components/template-file.test.d.ts +1 -1
- package/dist/test/components/template-file.test.d.ts.map +1 -1
- package/dist/test/components/template-file.test.js +0 -1
- package/dist/test/components/template-file.test.js.map +1 -1
- package/dist/test/components/update-file.test.d.ts +1 -1
- package/dist/test/components/update-file.test.d.ts.map +1 -1
- package/dist/test/components/update-file.test.js +0 -1
- package/dist/test/components/update-file.test.js.map +1 -1
- package/dist/test/components/wrap.test.d.ts +1 -1
- package/dist/test/components/wrap.test.d.ts.map +1 -1
- package/dist/test/components/wrap.test.js +3 -5
- package/dist/test/components/wrap.test.js.map +1 -1
- package/dist/test/control-flow/for.test.d.ts +1 -1
- package/dist/test/control-flow/for.test.d.ts.map +1 -1
- package/dist/test/control-flow/for.test.js +40 -24
- package/dist/test/control-flow/for.test.js.map +1 -1
- package/dist/test/control-flow/match.test.d.ts +1 -1
- package/dist/test/control-flow/match.test.d.ts.map +1 -1
- package/dist/test/control-flow/match.test.js +4 -6
- package/dist/test/control-flow/match.test.js.map +1 -1
- package/dist/test/control-flow/show.test.d.ts +1 -1
- package/dist/test/control-flow/show.test.d.ts.map +1 -1
- package/dist/test/control-flow/show.test.js +3 -6
- package/dist/test/control-flow/show.test.js.map +1 -1
- package/dist/test/lazy-isempty.test.d.ts +1 -1
- package/dist/test/lazy-isempty.test.d.ts.map +1 -1
- package/dist/test/lazy-isempty.test.js +11 -13
- package/dist/test/lazy-isempty.test.js.map +1 -1
- package/dist/test/name-policy.test.d.ts +1 -1
- package/dist/test/name-policy.test.d.ts.map +1 -1
- package/dist/test/name-policy.test.js +0 -1
- package/dist/test/name-policy.test.js.map +1 -1
- package/dist/test/reactivity/circular-reactives.test.js +6 -6
- package/dist/test/reactivity/circular-reactives.test.js.map +1 -1
- package/dist/test/reactivity/cleanup.test.js +2 -3
- package/dist/test/reactivity/cleanup.test.js.map +1 -1
- package/dist/test/reactivity/ref-rendering.test.js +15 -15
- package/dist/test/reactivity/ref-rendering.test.js.map +1 -1
- package/dist/test/reactivity/test.test.js +15 -15
- package/dist/test/reactivity/test.test.js.map +1 -1
- package/dist/test/rendering/basic.test.d.ts +1 -1
- package/dist/test/rendering/basic.test.d.ts.map +1 -1
- package/dist/test/rendering/basic.test.js +0 -1
- package/dist/test/rendering/basic.test.js.map +1 -1
- package/dist/test/rendering/code.test.d.ts +1 -1
- package/dist/test/rendering/code.test.d.ts.map +1 -1
- package/dist/test/rendering/code.test.js +0 -1
- package/dist/test/rendering/code.test.js.map +1 -1
- package/dist/test/rendering/formatting.test.d.ts +1 -1
- package/dist/test/rendering/formatting.test.d.ts.map +1 -1
- package/dist/test/rendering/formatting.test.js +17 -23
- package/dist/test/rendering/formatting.test.js.map +1 -1
- package/dist/test/rendering/indent.test.d.ts +1 -1
- package/dist/test/rendering/indent.test.d.ts.map +1 -1
- package/dist/test/rendering/indent.test.js +0 -1
- package/dist/test/rendering/indent.test.js.map +1 -1
- package/dist/test/rendering/memoization.test.js +2 -3
- package/dist/test/rendering/memoization.test.js.map +1 -1
- package/dist/test/rendering/print-render-stack.test.d.ts +1 -1
- package/dist/test/rendering/print-render-stack.test.d.ts.map +1 -1
- package/dist/test/rendering/print-render-stack.test.js +0 -1
- package/dist/test/rendering/print-render-stack.test.js.map +1 -1
- package/dist/test/rendering/refkeys.test.d.ts +1 -1
- package/dist/test/rendering/refkeys.test.d.ts.map +1 -1
- package/dist/test/rendering/refkeys.test.js +0 -1
- package/dist/test/rendering/refkeys.test.js.map +1 -1
- package/dist/test/stc.test.d.ts +1 -1
- package/dist/test/stc.test.d.ts.map +1 -1
- package/dist/test/stc.test.js +0 -1
- package/dist/test/stc.test.js.map +1 -1
- package/dist/test/utils.test.d.ts +1 -1
- package/dist/test/utils.test.d.ts.map +1 -1
- package/dist/test/utils.test.js +12 -11
- package/dist/test/utils.test.js.map +1 -1
- package/dist/test/vitest.setup.d.ts +2 -0
- package/dist/test/vitest.setup.d.ts.map +1 -0
- package/dist/test/vitest.setup.js +2 -0
- package/dist/test/vitest.setup.js.map +1 -0
- package/dist/testing/extend-expect.d.ts.map +1 -1
- package/dist/testing/extend-expect.js +23 -1
- package/dist/testing/extend-expect.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/AccessExpression.test.tsx +5 -13
- package/src/content-slot.test.tsx +8 -10
- package/src/symbols/symbol-slot.test.tsx +4 -4
- package/test/children.test.tsx +4 -7
- package/test/components/append-file.test.tsx +0 -1
- package/test/components/block.test.tsx +4 -6
- package/test/components/copy-file.test.tsx +0 -1
- package/test/components/declaration.test.tsx +2 -2
- package/test/components/list.test.tsx +20 -29
- package/test/components/prose.test.tsx +0 -1
- package/test/components/reference-or-content.test.tsx +8 -9
- package/test/components/source-file.test.tsx +4 -4
- package/test/components/template-file.test.tsx +0 -1
- package/test/components/update-file.test.tsx +0 -1
- package/test/components/wrap.test.tsx +3 -5
- package/test/control-flow/for.test.tsx +39 -31
- package/test/control-flow/match.test.tsx +4 -6
- package/test/control-flow/show.test.tsx +3 -6
- package/test/lazy-isempty.test.tsx +12 -14
- package/test/name-policy.test.tsx +0 -1
- package/test/reactivity/circular-reactives.test.tsx +6 -6
- package/test/reactivity/cleanup.test.tsx +2 -3
- package/test/reactivity/ref-rendering.test.tsx +15 -15
- package/test/reactivity/test.test.tsx +14 -14
- package/test/rendering/basic.test.tsx +0 -1
- package/test/rendering/code.test.tsx +0 -1
- package/test/rendering/formatting.test.tsx +21 -29
- package/test/rendering/indent.test.tsx +0 -1
- package/test/rendering/memoization.test.tsx +2 -3
- package/test/rendering/print-render-stack.test.tsx +0 -1
- package/test/rendering/refkeys.test.tsx +0 -1
- package/test/stc.test.tsx +0 -1
- package/test/utils.test.tsx +10 -9
- package/test/vitest.setup.ts +1 -0
- package/testing/extend-expect.ts +24 -1
- package/vitest.config.ts +3 -0
package/package.json
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import "../../testing/extend-expect.js";
|
|
3
2
|
import {
|
|
4
3
|
BasePartProps,
|
|
5
4
|
createAccessExpression,
|
|
6
5
|
} from "../components/AccessExpression.jsx";
|
|
7
6
|
import { code } from "../index.js";
|
|
8
7
|
import { Children } from "../runtime/component.js";
|
|
9
|
-
import { printTree, renderTree } from "../test-render.js";
|
|
10
8
|
|
|
11
9
|
interface TestPartProps extends BasePartProps {
|
|
12
10
|
name?: string;
|
|
@@ -105,28 +103,22 @@ describe("createAccessExpression", () => {
|
|
|
105
103
|
|
|
106
104
|
describe("createAccessExpression: call chain formatting", () => {
|
|
107
105
|
it("uses linear format with only one call", () => {
|
|
108
|
-
|
|
106
|
+
expect(
|
|
109
107
|
<Expression>
|
|
110
108
|
<Part name="foo" />
|
|
111
109
|
<Part name="bar" args="x" />
|
|
112
110
|
</Expression>,
|
|
113
|
-
);
|
|
114
|
-
// Single call → linear, no grouping.
|
|
115
|
-
expect(printTree(tree)).toBe("foo.bar(x)");
|
|
111
|
+
).toRenderTo("foo.bar(x)");
|
|
116
112
|
});
|
|
117
113
|
|
|
118
114
|
it("uses call chain format with multiple calls", () => {
|
|
119
|
-
|
|
115
|
+
// Multiple calls → call chain with group/indent wrapping.
|
|
116
|
+
expect(
|
|
120
117
|
<Expression>
|
|
121
118
|
<Part name="foo" />
|
|
122
119
|
<Part name="bar" args="x" />
|
|
123
120
|
<Part name="baz" args="y" />
|
|
124
121
|
</Expression>,
|
|
125
|
-
);
|
|
126
|
-
// Multiple calls → call chain with group/indent wrapping.
|
|
127
|
-
const result = printTree(tree);
|
|
128
|
-
// Should contain both calls.
|
|
129
|
-
expect(result).toContain("bar(x)");
|
|
130
|
-
expect(result).toContain("baz(y)");
|
|
122
|
+
).toRenderTo("foo.bar(x).baz(y)");
|
|
131
123
|
});
|
|
132
124
|
});
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { ref } from "@vue/reactivity";
|
|
2
2
|
import { expect, it } from "vitest";
|
|
3
|
-
import "../testing/extend-expect.js";
|
|
4
3
|
import { Show } from "./components/Show.jsx";
|
|
5
4
|
import { createContentSlot } from "./content-slot.jsx";
|
|
6
|
-
import { printTree, renderTree } from "./test-render.js";
|
|
7
5
|
|
|
8
6
|
it("knows when its empty", () => {
|
|
9
7
|
const ContentSlot = createContentSlot();
|
|
@@ -31,35 +29,35 @@ it("is reactive", () => {
|
|
|
31
29
|
const ContentSlot = createContentSlot();
|
|
32
30
|
const showContent = ref(false);
|
|
33
31
|
|
|
34
|
-
const tree =
|
|
32
|
+
const tree = (
|
|
35
33
|
<>
|
|
36
34
|
{ContentSlot.isEmpty && "It's empty!"}
|
|
37
35
|
<ContentSlot>
|
|
38
36
|
<Show when={showContent.value}>Content!</Show>
|
|
39
37
|
</ContentSlot>
|
|
40
|
-
|
|
38
|
+
</>
|
|
41
39
|
);
|
|
42
40
|
|
|
43
|
-
expect(
|
|
41
|
+
expect(tree).toRenderTo("It's empty!");
|
|
44
42
|
showContent.value = true;
|
|
45
|
-
expect(
|
|
43
|
+
expect(tree).toRenderTo("Content!");
|
|
46
44
|
});
|
|
47
45
|
|
|
48
46
|
it("works with WhenEmpty and WhenHasContent", () => {
|
|
49
47
|
const ContentSlot = createContentSlot();
|
|
50
48
|
const showContent = ref(false);
|
|
51
49
|
|
|
52
|
-
const tree =
|
|
50
|
+
const tree = (
|
|
53
51
|
<>
|
|
54
52
|
<ContentSlot.WhenEmpty>It's empty!</ContentSlot.WhenEmpty>
|
|
55
53
|
<ContentSlot.WhenHasContent>Has content!</ContentSlot.WhenHasContent>
|
|
56
54
|
<ContentSlot>
|
|
57
55
|
<Show when={showContent.value}>Content!</Show>
|
|
58
56
|
</ContentSlot>
|
|
59
|
-
|
|
57
|
+
</>
|
|
60
58
|
);
|
|
61
59
|
|
|
62
|
-
expect(
|
|
60
|
+
expect(tree).toRenderTo("It's empty!");
|
|
63
61
|
showContent.value = true;
|
|
64
|
-
expect(
|
|
62
|
+
expect(tree).toRenderTo("Has content!Content!");
|
|
65
63
|
});
|
|
@@ -9,13 +9,13 @@ import { createSymbolSlot } from "./symbol-slot.jsx";
|
|
|
9
9
|
it("captures firstSymbol", async () => {
|
|
10
10
|
const Slot = createSymbolSlot();
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
expect(
|
|
13
13
|
<Slot>
|
|
14
14
|
{() => {
|
|
15
15
|
emitSymbol(new BasicSymbol("a", undefined));
|
|
16
16
|
}}
|
|
17
17
|
</Slot>,
|
|
18
|
-
);
|
|
18
|
+
).toRenderTo("");
|
|
19
19
|
await flushJobs();
|
|
20
20
|
expect(Slot.firstSymbol.value).toBeDefined();
|
|
21
21
|
expect(Slot.firstSymbol.value!.name).toBe("a");
|
|
@@ -52,13 +52,13 @@ it("captures firstSymbol when emitting a ref to a symbol", async () => {
|
|
|
52
52
|
const Slot = createSymbolSlot();
|
|
53
53
|
const symref = shallowRef<BasicSymbol | undefined>();
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
expect(
|
|
56
56
|
<Slot>
|
|
57
57
|
{() => {
|
|
58
58
|
emitSymbol(symref);
|
|
59
59
|
}}
|
|
60
60
|
</Slot>,
|
|
61
|
-
);
|
|
61
|
+
).toRenderTo("");
|
|
62
62
|
await flushJobs();
|
|
63
63
|
expect(Slot.firstSymbol.value).toBeUndefined();
|
|
64
64
|
symref.value = new BasicSymbol("a", undefined);
|
package/test/children.test.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { children, Children
|
|
1
|
+
import { children, Children } from "@alloy-js/core";
|
|
2
2
|
import { expect, it } from "vitest";
|
|
3
3
|
|
|
4
4
|
it("handles a single element", () => {
|
|
@@ -6,8 +6,7 @@ it("handles a single element", () => {
|
|
|
6
6
|
return children(() => props.children);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
expect(printTree(res)).toBe("a b c");
|
|
9
|
+
expect(<Foo>a b c</Foo>).toRenderTo("a b c");
|
|
11
10
|
});
|
|
12
11
|
|
|
13
12
|
it("handles a multiple elements", () => {
|
|
@@ -20,12 +19,10 @@ it("handles a multiple elements", () => {
|
|
|
20
19
|
return "Bar";
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
|
|
22
|
+
expect(
|
|
24
23
|
<Foo>
|
|
25
24
|
<Bar />
|
|
26
25
|
<Bar />
|
|
27
26
|
</Foo>,
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
expect(printTree(res)).toBe(`BarBar`);
|
|
27
|
+
).toRenderTo(`BarBar`);
|
|
31
28
|
});
|
|
@@ -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 "../../testing/extend-expect.js";
|
|
7
6
|
import { d } from "../../testing/render.js";
|
|
8
7
|
|
|
9
8
|
describe("AppendFile", () => {
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { ref } from "@vue/reactivity";
|
|
2
2
|
import { expect, it } from "vitest";
|
|
3
3
|
import { Block } from "../../src/components/Block.jsx";
|
|
4
|
-
import { printTree, renderTree } from "../../src/test-render.js";
|
|
5
|
-
import "../../testing/extend-expect.js";
|
|
6
4
|
it("renders properly with no children", () => {
|
|
7
5
|
const template = (
|
|
8
6
|
<Block>
|
|
@@ -51,16 +49,16 @@ it("renders properly with newline and children", () => {
|
|
|
51
49
|
|
|
52
50
|
it("renders properly when content is added reactively", () => {
|
|
53
51
|
const contents = ref("");
|
|
54
|
-
const tree =
|
|
52
|
+
const tree = (
|
|
55
53
|
<>
|
|
56
54
|
class Foo <Block>{contents}</Block>
|
|
57
|
-
|
|
55
|
+
</>
|
|
58
56
|
);
|
|
59
|
-
expect(
|
|
57
|
+
expect(tree).toRenderTo(`
|
|
60
58
|
class Foo {}
|
|
61
59
|
`);
|
|
62
60
|
contents.value = "x = 12;";
|
|
63
|
-
expect(
|
|
61
|
+
expect(tree).toRenderTo(`
|
|
64
62
|
class Foo {
|
|
65
63
|
x = 12;
|
|
66
64
|
}
|
|
@@ -7,7 +7,6 @@ import { SourceDirectory } from "../../src/components/SourceDirectory.jsx";
|
|
|
7
7
|
import type { CopyOutputFile } from "../../src/output-types.js";
|
|
8
8
|
import { render } from "../../src/render-output.js";
|
|
9
9
|
import { writeOutput } from "../../src/write-output.js";
|
|
10
|
-
import "../../testing/extend-expect.js";
|
|
11
10
|
|
|
12
11
|
describe("CopyFile", () => {
|
|
13
12
|
let testDir: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { expect, it } from "vitest";
|
|
2
2
|
import { Output } from "../../src/components/Output.jsx";
|
|
3
|
-
import { Declaration, ref,
|
|
3
|
+
import { Declaration, ref, Scope } from "../../src/index.js";
|
|
4
4
|
import { flushJobs } from "../../src/scheduler.js";
|
|
5
5
|
import { BasicScope } from "../../src/symbols/basic-scope.js";
|
|
6
6
|
|
|
@@ -17,7 +17,7 @@ it("creates and cleans up a symbol", () => {
|
|
|
17
17
|
</Output>
|
|
18
18
|
);
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
expect(template).toRenderTo("");
|
|
21
21
|
|
|
22
22
|
expect(scope.symbols.size).toBe(1);
|
|
23
23
|
doDecl.value = false;
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import { expect, it } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
createContentSlot,
|
|
4
|
-
List,
|
|
5
|
-
printTree,
|
|
6
|
-
ref,
|
|
7
|
-
renderTree,
|
|
8
|
-
Show,
|
|
9
|
-
} from "../../src/index.js";
|
|
10
|
-
import "../../testing/extend-expect.js";
|
|
11
|
-
import { d } from "../../testing/render.js";
|
|
2
|
+
import { createContentSlot, List, ref, Show } from "../../src/index.js";
|
|
12
3
|
|
|
13
4
|
it("creates a list with default options", () => {
|
|
14
5
|
const template = (
|
|
@@ -73,14 +64,14 @@ it("is useful for statements", () => {
|
|
|
73
64
|
return "console.log(true)";
|
|
74
65
|
}
|
|
75
66
|
const includeStatement = ref(false);
|
|
76
|
-
const tree =
|
|
67
|
+
const tree = (
|
|
77
68
|
<List semicolon hardline ender>
|
|
78
69
|
<Statement />
|
|
79
70
|
{includeStatement.value && <Statement />}
|
|
80
71
|
<Statement />
|
|
81
|
-
</List
|
|
72
|
+
</List>
|
|
82
73
|
);
|
|
83
|
-
expect(
|
|
74
|
+
expect(tree).toRenderTo(`
|
|
84
75
|
console.log(true);
|
|
85
76
|
console.log(true);
|
|
86
77
|
|
|
@@ -88,7 +79,7 @@ it("is useful for statements", () => {
|
|
|
88
79
|
|
|
89
80
|
includeStatement.value = true;
|
|
90
81
|
|
|
91
|
-
expect(
|
|
82
|
+
expect(tree).toRenderTo(`
|
|
92
83
|
console.log(true);
|
|
93
84
|
console.log(true);
|
|
94
85
|
console.log(true);
|
|
@@ -113,37 +104,37 @@ it("It add joiners when items are become non-empty", () => {
|
|
|
113
104
|
const item2 = ref("");
|
|
114
105
|
const item3 = ref("");
|
|
115
106
|
|
|
116
|
-
const tree =
|
|
107
|
+
const tree = (
|
|
117
108
|
<group>
|
|
118
109
|
<List comma line ender=";">
|
|
119
110
|
<>{item1}</>
|
|
120
111
|
<>{item2}</>
|
|
121
112
|
<>{item3}</>
|
|
122
113
|
</List>
|
|
123
|
-
</group
|
|
114
|
+
</group>
|
|
124
115
|
);
|
|
125
116
|
|
|
126
|
-
expect(
|
|
117
|
+
expect(tree).toRenderTo("");
|
|
127
118
|
item1.value = "hi";
|
|
128
|
-
expect(
|
|
119
|
+
expect(tree).toRenderTo("hi;");
|
|
129
120
|
item2.value = "there";
|
|
130
|
-
expect(
|
|
121
|
+
expect(tree).toRenderTo("hi, there;");
|
|
131
122
|
item3.value = "friend";
|
|
132
|
-
expect(
|
|
123
|
+
expect(tree).toRenderTo("hi, there, friend;");
|
|
133
124
|
|
|
134
125
|
item1.value = "";
|
|
135
|
-
expect(
|
|
126
|
+
expect(tree).toRenderTo("there, friend;");
|
|
136
127
|
item3.value = "";
|
|
137
|
-
expect(
|
|
128
|
+
expect(tree).toRenderTo("there;");
|
|
138
129
|
item2.value = "";
|
|
139
|
-
expect(
|
|
130
|
+
expect(tree).toRenderTo("");
|
|
140
131
|
});
|
|
141
132
|
|
|
142
133
|
it("works with show", () => {
|
|
143
134
|
const ContentSlot = createContentSlot();
|
|
144
135
|
const showFirst = ref(false);
|
|
145
136
|
const showSecond = ref(false);
|
|
146
|
-
const tree =
|
|
137
|
+
const tree = (
|
|
147
138
|
<>
|
|
148
139
|
<ContentSlot.WhenEmpty>Empty list!</ContentSlot.WhenEmpty>
|
|
149
140
|
<ContentSlot>
|
|
@@ -152,14 +143,14 @@ it("works with show", () => {
|
|
|
152
143
|
<Show when={showSecond.value}>Two</Show>
|
|
153
144
|
</List>
|
|
154
145
|
</ContentSlot>
|
|
155
|
-
|
|
146
|
+
</>
|
|
156
147
|
);
|
|
157
|
-
expect(
|
|
148
|
+
expect(tree).toRenderTo("Empty list!");
|
|
158
149
|
showFirst.value = true;
|
|
159
|
-
expect(
|
|
150
|
+
expect(tree).toRenderTo("One");
|
|
160
151
|
showSecond.value = true;
|
|
161
|
-
expect(
|
|
152
|
+
expect(tree).toRenderTo("One, Two");
|
|
162
153
|
showFirst.value = false;
|
|
163
154
|
showSecond.value = false;
|
|
164
|
-
expect(
|
|
155
|
+
expect(tree).toRenderTo("Empty list!");
|
|
165
156
|
});
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
SourceFile,
|
|
14
14
|
useBinder,
|
|
15
15
|
} from "../../src/index.js";
|
|
16
|
-
import { d, renderToString } from "../../testing/render.js";
|
|
17
16
|
|
|
18
17
|
function TestWrapper(props: { children: Children }) {
|
|
19
18
|
const GetBinder = createTap(() => useBinder());
|
|
@@ -47,7 +46,7 @@ describe("render the reference name if a declaration exists", () => {
|
|
|
47
46
|
</TestWrapper>
|
|
48
47
|
);
|
|
49
48
|
|
|
50
|
-
expect(
|
|
49
|
+
expect(template).toRenderTo(`
|
|
51
50
|
Declare A
|
|
52
51
|
A
|
|
53
52
|
`);
|
|
@@ -64,10 +63,10 @@ describe("render the reference name if a declaration exists", () => {
|
|
|
64
63
|
</TestWrapper>
|
|
65
64
|
);
|
|
66
65
|
|
|
67
|
-
expect(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
expect(template).toRenderTo(`
|
|
67
|
+
A
|
|
68
|
+
Declare A
|
|
69
|
+
`);
|
|
71
70
|
});
|
|
72
71
|
});
|
|
73
72
|
|
|
@@ -79,7 +78,7 @@ it("render content if there is not declaration attached to symbol", () => {
|
|
|
79
78
|
</TestWrapper>
|
|
80
79
|
);
|
|
81
80
|
|
|
82
|
-
expect(
|
|
81
|
+
expect(template).toRenderTo(`
|
|
83
82
|
No Reference A
|
|
84
83
|
`);
|
|
85
84
|
});
|
|
@@ -97,7 +96,7 @@ it("mixed", () => {
|
|
|
97
96
|
</TestWrapper>
|
|
98
97
|
);
|
|
99
98
|
|
|
100
|
-
expect(
|
|
99
|
+
expect(template).toRenderTo(`
|
|
101
100
|
Declare A
|
|
102
101
|
A
|
|
103
102
|
No Reference B
|
|
@@ -130,7 +129,7 @@ it("resolve ref via source file reference", () => {
|
|
|
130
129
|
</Output>
|
|
131
130
|
);
|
|
132
131
|
|
|
133
|
-
expect(
|
|
132
|
+
expect(template).toRenderTo(`
|
|
134
133
|
Declare A
|
|
135
134
|
ViaRef.A
|
|
136
135
|
`);
|
|
@@ -8,13 +8,11 @@ import {
|
|
|
8
8
|
Output,
|
|
9
9
|
Prose,
|
|
10
10
|
render,
|
|
11
|
-
renderTree,
|
|
12
11
|
SourceFile,
|
|
13
12
|
useContext,
|
|
14
13
|
} from "@alloy-js/core";
|
|
15
14
|
import { describe, expect, it } from "vitest";
|
|
16
15
|
import { SourceDirectoryContext } from "../../src/context/source-directory.js";
|
|
17
|
-
import "../../testing/extend-expect.js";
|
|
18
16
|
import { d } from "../../testing/render.js";
|
|
19
17
|
|
|
20
18
|
it("tracks its content", () => {
|
|
@@ -22,14 +20,16 @@ it("tracks its content", () => {
|
|
|
22
20
|
function Test() {
|
|
23
21
|
context = useContext(SourceDirectoryContext);
|
|
24
22
|
}
|
|
25
|
-
|
|
23
|
+
expect(
|
|
26
24
|
<Output>
|
|
27
25
|
<Test />
|
|
28
26
|
<SourceFile path="hi.txt" filetype="text">
|
|
29
27
|
hello!
|
|
30
28
|
</SourceFile>
|
|
31
29
|
</Output>,
|
|
32
|
-
)
|
|
30
|
+
).toRenderTo({
|
|
31
|
+
"hi.txt": "hello!",
|
|
32
|
+
});
|
|
33
33
|
expect(context!.contents.length).toEqual(1);
|
|
34
34
|
});
|
|
35
35
|
|
|
@@ -4,7 +4,6 @@ import { join } from "pathe";
|
|
|
4
4
|
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
5
5
|
import { UpdateFile } from "../../src/components/UpdateFile.jsx";
|
|
6
6
|
import { render } from "../../src/render-output.js";
|
|
7
|
-
import "../../testing/extend-expect.js";
|
|
8
7
|
import { d } from "../../testing/render.js";
|
|
9
8
|
|
|
10
9
|
describe("UpdateFile", () => {
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { ref } from "@vue/reactivity";
|
|
2
2
|
import { expect, it } from "vitest";
|
|
3
3
|
import { Wrap } from "../../src/components/Wrap.jsx";
|
|
4
|
-
import { printTree, renderTree } from "../../src/test-render.js";
|
|
5
|
-
import "../../testing/extend-expect.js";
|
|
6
4
|
|
|
7
5
|
function Wrapper(props: any) {
|
|
8
6
|
return <>[{props.children}]</>;
|
|
@@ -33,10 +31,10 @@ it("works reactively", () => {
|
|
|
33
31
|
</>
|
|
34
32
|
);
|
|
35
33
|
|
|
36
|
-
const tree =
|
|
37
|
-
expect(
|
|
34
|
+
const tree = template;
|
|
35
|
+
expect(tree).toRenderTo("testing");
|
|
38
36
|
|
|
39
37
|
doWrap.value = true;
|
|
40
38
|
|
|
41
|
-
expect(
|
|
39
|
+
expect(tree).toRenderTo("testing");
|
|
42
40
|
});
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import "@alloy-js/core/testing";
|
|
2
1
|
import { d } from "@alloy-js/core/testing";
|
|
3
2
|
import { describe, expect, it } from "vitest";
|
|
4
3
|
import { For } from "../../src/components/For.jsx";
|
|
5
|
-
import {
|
|
6
|
-
onCleanup,
|
|
7
|
-
printTree,
|
|
8
|
-
reactive,
|
|
9
|
-
ref,
|
|
10
|
-
renderTree,
|
|
11
|
-
} from "../../src/index.js";
|
|
4
|
+
import { onCleanup, reactive, ref } from "../../src/index.js";
|
|
12
5
|
import { flushJobs } from "../../src/scheduler.js";
|
|
13
6
|
|
|
14
7
|
it("works", () => {
|
|
@@ -103,14 +96,18 @@ it("doesn't rerender mappers", () => {
|
|
|
103
96
|
const messages = reactive(["hi", "bye"]);
|
|
104
97
|
let count = 0;
|
|
105
98
|
const template = <For each={messages}>{() => <>item {count++}</>}</For>;
|
|
106
|
-
const tree =
|
|
99
|
+
const tree = <>{template}</>;
|
|
100
|
+
expect(tree).toRenderTo(`
|
|
101
|
+
item 0
|
|
102
|
+
item 1
|
|
103
|
+
`);
|
|
107
104
|
expect(count).toBe(2);
|
|
108
105
|
|
|
109
106
|
messages.push("maybe");
|
|
110
107
|
flushJobs();
|
|
111
108
|
|
|
112
109
|
expect(count).toBe(3);
|
|
113
|
-
expect(
|
|
110
|
+
expect(tree).toRenderTo(`
|
|
114
111
|
item 0
|
|
115
112
|
item 1
|
|
116
113
|
item 2
|
|
@@ -121,13 +118,17 @@ it("doesn't rerender mappers with sets", () => {
|
|
|
121
118
|
const messages = reactive(new Set(["hi", "bye"]));
|
|
122
119
|
let count = 0;
|
|
123
120
|
const template = <For each={messages}>{() => <>item {count++}</>}</For>;
|
|
124
|
-
const tree =
|
|
121
|
+
const tree = <>{template}</>;
|
|
122
|
+
expect(tree).toRenderTo(`
|
|
123
|
+
item 0
|
|
124
|
+
item 1
|
|
125
|
+
`);
|
|
125
126
|
expect(count).toBe(2);
|
|
126
127
|
|
|
127
128
|
messages.add("maybe");
|
|
128
129
|
flushJobs();
|
|
129
130
|
expect(count).toBe(3);
|
|
130
|
-
expect(
|
|
131
|
+
expect(tree).toRenderTo(`
|
|
131
132
|
item 0
|
|
132
133
|
item 1
|
|
133
134
|
item 2
|
|
@@ -144,13 +145,17 @@ it("doesn't rerender mappers with maps", () => {
|
|
|
144
145
|
|
|
145
146
|
let count = 0;
|
|
146
147
|
const template = <For each={messages}>{() => <>item {count++}</>}</For>;
|
|
147
|
-
const tree =
|
|
148
|
+
const tree = <>{template}</>;
|
|
149
|
+
expect(tree).toRenderTo(`
|
|
150
|
+
item 0
|
|
151
|
+
item 1
|
|
152
|
+
`);
|
|
148
153
|
expect(count).toBe(2);
|
|
149
154
|
|
|
150
155
|
messages.set("maybe", "three");
|
|
151
156
|
flushJobs();
|
|
152
157
|
expect(count).toBe(3);
|
|
153
|
-
expect(
|
|
158
|
+
expect(tree).toRenderTo(`
|
|
154
159
|
item 0
|
|
155
160
|
item 1
|
|
156
161
|
item 2
|
|
@@ -167,7 +172,12 @@ it("doesn't rerender mappers (with splice)", () => {
|
|
|
167
172
|
}}
|
|
168
173
|
</For>
|
|
169
174
|
);
|
|
170
|
-
const tree =
|
|
175
|
+
const tree = <>{template}</>;
|
|
176
|
+
expect(tree).toRenderTo(`
|
|
177
|
+
item 0
|
|
178
|
+
item 1
|
|
179
|
+
item 2
|
|
180
|
+
`);
|
|
171
181
|
expect(count).toBe(3);
|
|
172
182
|
messages.splice(1, 1);
|
|
173
183
|
flushJobs();
|
|
@@ -175,7 +185,7 @@ it("doesn't rerender mappers (with splice)", () => {
|
|
|
175
185
|
// but for now we re-render everything after the splice point.
|
|
176
186
|
expect(count).toBe(4);
|
|
177
187
|
|
|
178
|
-
expect(
|
|
188
|
+
expect(tree).toRenderTo(`
|
|
179
189
|
item 0
|
|
180
190
|
item 3
|
|
181
191
|
`);
|
|
@@ -196,10 +206,10 @@ it("cleans up things which end up removed (with push)", () => {
|
|
|
196
206
|
|
|
197
207
|
const template = <For each={items}>{(item) => <Letter letter={item} />}</For>;
|
|
198
208
|
|
|
199
|
-
const tree =
|
|
209
|
+
const tree = <>{template}</>;
|
|
200
210
|
|
|
201
211
|
expect(cleanups).toEqual([]);
|
|
202
|
-
expect(
|
|
212
|
+
expect(tree).toRenderTo(`
|
|
203
213
|
Letter a
|
|
204
214
|
Letter b
|
|
205
215
|
`);
|
|
@@ -207,14 +217,14 @@ it("cleans up things which end up removed (with push)", () => {
|
|
|
207
217
|
items.pop();
|
|
208
218
|
flushJobs();
|
|
209
219
|
expect(cleanups).toEqual(["b"]);
|
|
210
|
-
expect(
|
|
220
|
+
expect(tree).toRenderTo(`
|
|
211
221
|
Letter a
|
|
212
222
|
`);
|
|
213
223
|
|
|
214
224
|
items.pop();
|
|
215
225
|
flushJobs();
|
|
216
226
|
expect(cleanups).toEqual(["b", "a"]);
|
|
217
|
-
expect(
|
|
227
|
+
expect(tree).toRenderTo("");
|
|
218
228
|
});
|
|
219
229
|
|
|
220
230
|
it("cleans up things which end up removed (with splice)", () => {
|
|
@@ -232,10 +242,10 @@ it("cleans up things which end up removed (with splice)", () => {
|
|
|
232
242
|
|
|
233
243
|
const template = <For each={items}>{(item) => <Letter letter={item} />}</For>;
|
|
234
244
|
|
|
235
|
-
const tree =
|
|
245
|
+
const tree = <>{template}</>;
|
|
236
246
|
|
|
237
247
|
expect(cleanups).toEqual([]);
|
|
238
|
-
expect(
|
|
248
|
+
expect(tree).toRenderTo(`
|
|
239
249
|
Letter a
|
|
240
250
|
Letter b
|
|
241
251
|
Letter c
|
|
@@ -246,7 +256,7 @@ it("cleans up things which end up removed (with splice)", () => {
|
|
|
246
256
|
// A sufficiently smart mapJoin would be able to handle this case...
|
|
247
257
|
// but for now we re-render everything after the splice point.
|
|
248
258
|
expect(cleanups).toEqual(["b", "c"]);
|
|
249
|
-
expect(
|
|
259
|
+
expect(tree).toRenderTo(`
|
|
250
260
|
Letter a
|
|
251
261
|
Letter c
|
|
252
262
|
`);
|
|
@@ -254,10 +264,8 @@ it("cleans up things which end up removed (with splice)", () => {
|
|
|
254
264
|
|
|
255
265
|
it("doesn't render empty content", () => {
|
|
256
266
|
const items = [1, 2, 3];
|
|
257
|
-
const tree =
|
|
258
|
-
|
|
259
|
-
);
|
|
260
|
-
expect(printTree(tree)).toBe(`3`);
|
|
267
|
+
const tree = <For each={items}>{(item) => (item > 2 ? item : null)}</For>;
|
|
268
|
+
expect(tree).toRenderTo("3");
|
|
261
269
|
});
|
|
262
270
|
|
|
263
271
|
it("updates joiners appropriately when items get/lose content", () => {
|
|
@@ -267,16 +275,16 @@ it("updates joiners appropriately when items get/lose content", () => {
|
|
|
267
275
|
{ content: ref("hello") },
|
|
268
276
|
];
|
|
269
277
|
|
|
270
|
-
const tree =
|
|
278
|
+
const tree = (
|
|
271
279
|
<For each={items} joiner=", ">
|
|
272
280
|
{(item) => {
|
|
273
281
|
return item.content;
|
|
274
282
|
}}
|
|
275
|
-
</For
|
|
283
|
+
</For>
|
|
276
284
|
);
|
|
277
285
|
|
|
278
|
-
expect(
|
|
286
|
+
expect(tree).toRenderTo("hello");
|
|
279
287
|
items[1].content.value = "hi";
|
|
280
288
|
flushJobs();
|
|
281
|
-
expect(
|
|
289
|
+
expect(tree).toRenderTo("hi, hello");
|
|
282
290
|
});
|