@alloy-js/core 0.19.0-dev.0 → 0.19.0-dev.12
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 +14 -0
- package/dist/src/components/AppendFile.d.ts +90 -0
- package/dist/src/components/AppendFile.d.ts.map +1 -0
- package/dist/src/components/AppendFile.js +226 -0
- package/dist/src/components/CopyFile.d.ts +12 -0
- package/dist/src/components/CopyFile.d.ts.map +1 -0
- package/dist/src/components/CopyFile.js +15 -0
- package/dist/src/components/TemplateFile.d.ts +84 -0
- package/dist/src/components/TemplateFile.d.ts.map +1 -0
- package/dist/src/components/TemplateFile.js +133 -0
- package/dist/src/components/UpdateFile.d.ts +34 -0
- package/dist/src/components/UpdateFile.d.ts.map +1 -0
- package/dist/src/components/UpdateFile.js +66 -0
- package/dist/src/components/index.d.ts +4 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +4 -0
- package/dist/src/components/stc/index.d.ts +4 -0
- package/dist/src/components/stc/index.d.ts.map +1 -1
- package/dist/src/components/stc/index.js +4 -0
- package/dist/src/context/source-directory.d.ts +3 -3
- package/dist/src/context/source-directory.d.ts.map +1 -1
- package/dist/src/context/source-file.d.ts +4 -0
- package/dist/src/context/source-file.d.ts.map +1 -1
- package/dist/src/debug.d.ts.map +1 -1
- package/dist/src/debug.js +4 -1
- package/dist/src/host/alloy-host.browser.d.ts +11 -0
- package/dist/src/host/alloy-host.browser.d.ts.map +1 -0
- package/dist/src/host/alloy-host.browser.js +31 -0
- package/dist/src/host/alloy-host.d.ts +11 -0
- package/dist/src/host/alloy-host.d.ts.map +1 -0
- package/dist/src/host/alloy-host.js +143 -0
- package/dist/src/host/interface.d.ts +144 -0
- package/dist/src/host/interface.d.ts.map +1 -0
- package/dist/src/host/interface.js +1 -0
- package/dist/src/index.browser.d.ts +1 -1
- package/dist/src/index.browser.d.ts.map +1 -1
- package/dist/src/index.browser.js +2 -2
- package/dist/src/reactivity.js +2 -2
- package/dist/src/render.d.ts +10 -2
- package/dist/src/render.d.ts.map +1 -1
- package/dist/src/render.js +20 -1
- package/dist/src/resource.d.ts +80 -0
- package/dist/src/resource.d.ts.map +1 -0
- package/dist/src/resource.js +118 -0
- package/dist/src/scheduler.d.ts +6 -0
- package/dist/src/scheduler.d.ts.map +1 -1
- package/dist/src/scheduler.js +36 -0
- package/dist/src/write-output.d.ts +1 -1
- package/dist/src/write-output.d.ts.map +1 -1
- package/dist/src/write-output.js +40 -21
- package/dist/test/components/append-file.test.d.ts +2 -0
- package/dist/test/components/append-file.test.d.ts.map +1 -0
- package/dist/test/components/append-file.test.js +281 -0
- package/dist/test/components/copy-file.test.d.ts +2 -0
- package/dist/test/components/copy-file.test.d.ts.map +1 -0
- package/dist/test/components/copy-file.test.js +94 -0
- package/dist/test/components/source-file.test.d.ts.map +1 -1
- package/dist/test/components/template-file.test.d.ts +2 -0
- package/dist/test/components/template-file.test.d.ts.map +1 -0
- package/dist/test/components/template-file.test.js +133 -0
- package/dist/test/components/update-file.test.d.ts +2 -0
- package/dist/test/components/update-file.test.d.ts.map +1 -0
- package/dist/test/components/update-file.test.js +169 -0
- package/dist/test/rendering/formatting.test.d.ts.map +1 -1
- package/dist/testing/extend-expect.d.ts +0 -15
- package/dist/testing/extend-expect.d.ts.map +1 -1
- package/dist/testing/extend-expect.js +89 -12
- package/dist/testing/extend-expect.test.d.ts +2 -0
- package/dist/testing/extend-expect.test.d.ts.map +1 -0
- package/dist/testing/extend-expect.test.js +149 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/components/AppendFile.tsx +294 -0
- package/src/components/CopyFile.tsx +29 -0
- package/src/components/TemplateFile.tsx +193 -0
- package/src/components/UpdateFile.tsx +86 -0
- package/src/components/index.tsx +4 -0
- package/src/components/stc/index.ts +4 -0
- package/src/context/source-directory.ts +5 -3
- package/src/context/source-file.ts +5 -0
- package/src/debug.ts +4 -1
- package/src/host/alloy-host.browser.ts +56 -0
- package/src/host/alloy-host.ts +160 -0
- package/src/host/interface.ts +153 -0
- package/src/index.browser.ts +1 -1
- package/src/reactivity.ts +2 -2
- package/src/render.ts +44 -5
- package/src/resource.ts +152 -0
- package/src/scheduler.ts +39 -0
- package/src/write-output.ts +49 -19
- package/temp/api.json +2009 -546
- package/test/components/append-file.test.tsx +275 -0
- package/test/components/copy-file.test.tsx +98 -0
- package/test/components/source-file.test.tsx +5 -2
- package/test/components/template-file.test.tsx +127 -0
- package/test/components/update-file.test.tsx +214 -0
- package/test/rendering/formatting.test.tsx +9 -3
- package/testing/extend-expect.test.tsx +126 -0
- package/testing/extend-expect.ts +123 -23
- package/testing/vitest.d.ts +9 -1
- package/tsconfig.json +2 -1
- package/dist/src/write-output.browser.d.ts +0 -2
- package/dist/src/write-output.browser.d.ts.map +0 -1
- package/dist/src/write-output.browser.js +0 -4
- package/src/write-output.browser.ts +0 -4
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { Indent, Output, SourceDirectory, SourceFile } from "@alloy-js/core";
|
|
3
|
+
import { describe, expect, it } from "vitest";
|
|
4
|
+
import "./extend-expect.js";
|
|
5
|
+
describe("toRenderTo", () => {
|
|
6
|
+
it("can validate structure without source files", () => {
|
|
7
|
+
expect(["base", _$createComponent(Indent, {
|
|
8
|
+
children: "indented"
|
|
9
|
+
})]).toRenderTo(`
|
|
10
|
+
base
|
|
11
|
+
indented
|
|
12
|
+
`);
|
|
13
|
+
});
|
|
14
|
+
it("can expect the content of the single source file used", () => {
|
|
15
|
+
expect(_$createComponent(Output, {
|
|
16
|
+
get children() {
|
|
17
|
+
return _$createComponent(SourceFile, {
|
|
18
|
+
path: "Test.cs",
|
|
19
|
+
tabWidth: 4,
|
|
20
|
+
filetype: "csharp",
|
|
21
|
+
get children() {
|
|
22
|
+
return ["base", _$createComponent(Indent, {
|
|
23
|
+
children: "indented"
|
|
24
|
+
})];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
})).toRenderTo(`
|
|
29
|
+
base
|
|
30
|
+
indented
|
|
31
|
+
`);
|
|
32
|
+
});
|
|
33
|
+
it("expect with specific file name", () => {
|
|
34
|
+
expect(_$createComponent(Output, {
|
|
35
|
+
get children() {
|
|
36
|
+
return _$createComponent(SourceFile, {
|
|
37
|
+
path: "Test.cs",
|
|
38
|
+
tabWidth: 4,
|
|
39
|
+
filetype: "csharp",
|
|
40
|
+
get children() {
|
|
41
|
+
return ["base", _$createComponent(Indent, {
|
|
42
|
+
children: "indented"
|
|
43
|
+
})];
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
})).toRenderTo({
|
|
48
|
+
"Test.cs": `
|
|
49
|
+
base
|
|
50
|
+
indented
|
|
51
|
+
`
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
it("expect with specific file name in SourceDirectory", () => {
|
|
55
|
+
expect(_$createComponent(Output, {
|
|
56
|
+
get children() {
|
|
57
|
+
return _$createComponent(SourceDirectory, {
|
|
58
|
+
path: "src",
|
|
59
|
+
get children() {
|
|
60
|
+
return _$createComponent(SourceFile, {
|
|
61
|
+
path: "test.txt",
|
|
62
|
+
filetype: "text",
|
|
63
|
+
children: "content"
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
})).toRenderTo({
|
|
69
|
+
"src/test.txt": `
|
|
70
|
+
content
|
|
71
|
+
`
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
it("each source file respect their print options", () => {
|
|
75
|
+
expect(_$createComponent(Output, {
|
|
76
|
+
get children() {
|
|
77
|
+
return [_$createComponent(SourceFile, {
|
|
78
|
+
path: "Test.cs",
|
|
79
|
+
tabWidth: 4,
|
|
80
|
+
filetype: "csharp",
|
|
81
|
+
get children() {
|
|
82
|
+
return ["base1", _$createComponent(Indent, {
|
|
83
|
+
children: "indented"
|
|
84
|
+
})];
|
|
85
|
+
}
|
|
86
|
+
}), _$createComponent(SourceFile, {
|
|
87
|
+
path: "Test.ts",
|
|
88
|
+
tabWidth: 2,
|
|
89
|
+
filetype: "csharp",
|
|
90
|
+
get children() {
|
|
91
|
+
return ["base2", _$createComponent(Indent, {
|
|
92
|
+
children: "indented"
|
|
93
|
+
})];
|
|
94
|
+
}
|
|
95
|
+
})];
|
|
96
|
+
}
|
|
97
|
+
})).toRenderTo({
|
|
98
|
+
"Test.cs": `
|
|
99
|
+
base1
|
|
100
|
+
indented
|
|
101
|
+
`,
|
|
102
|
+
"Test.ts": `
|
|
103
|
+
base2
|
|
104
|
+
indented
|
|
105
|
+
`
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
it("fails when content does not match", () => {
|
|
109
|
+
expect(() => expect(["base", _$createComponent(Indent, {
|
|
110
|
+
children: "indented"
|
|
111
|
+
})]).toRenderTo(`
|
|
112
|
+
base
|
|
113
|
+
wrong
|
|
114
|
+
`)).toThrowError(/Render is incorrect/);
|
|
115
|
+
});
|
|
116
|
+
it("fails when files don't match", () => {
|
|
117
|
+
expect(() => expect(_$createComponent(Output, {
|
|
118
|
+
get children() {
|
|
119
|
+
return [_$createComponent(SourceFile, {
|
|
120
|
+
path: "Test.cs",
|
|
121
|
+
tabWidth: 4,
|
|
122
|
+
filetype: "csharp",
|
|
123
|
+
get children() {
|
|
124
|
+
return ["base1", _$createComponent(Indent, {
|
|
125
|
+
children: "indented"
|
|
126
|
+
})];
|
|
127
|
+
}
|
|
128
|
+
}), _$createComponent(SourceFile, {
|
|
129
|
+
path: "Test.ts",
|
|
130
|
+
tabWidth: 2,
|
|
131
|
+
filetype: "typescript",
|
|
132
|
+
get children() {
|
|
133
|
+
return ["base2", _$createComponent(Indent, {
|
|
134
|
+
children: "indented"
|
|
135
|
+
})];
|
|
136
|
+
}
|
|
137
|
+
})];
|
|
138
|
+
}
|
|
139
|
+
})).toRenderTo({
|
|
140
|
+
"Test.cs": `
|
|
141
|
+
bad
|
|
142
|
+
`,
|
|
143
|
+
"Test.ts": `
|
|
144
|
+
base2
|
|
145
|
+
indented
|
|
146
|
+
`
|
|
147
|
+
})).toThrowError(/Render is incorrect/);
|
|
148
|
+
});
|
|
149
|
+
});
|