@alloy-js/core 0.4.0 → 0.6.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.
Files changed (228) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/babel.config.cjs +4 -1
  3. package/dist/src/binder.d.ts +20 -13
  4. package/dist/src/binder.d.ts.map +1 -1
  5. package/dist/src/binder.js +33 -15
  6. package/dist/src/binder.js.map +1 -1
  7. package/dist/src/code.d.ts +2 -2
  8. package/dist/src/code.d.ts.map +1 -1
  9. package/dist/src/code.js +4 -4
  10. package/dist/src/code.js.map +1 -1
  11. package/dist/src/components/Block.d.ts +25 -0
  12. package/dist/src/components/Block.d.ts.map +1 -0
  13. package/dist/src/components/Block.js +25 -0
  14. package/dist/src/components/Block.js.map +1 -0
  15. package/dist/src/components/Declaration.d.ts +1 -1
  16. package/dist/src/components/Declaration.d.ts.map +1 -1
  17. package/dist/src/components/Declaration.js +4 -0
  18. package/dist/src/components/Declaration.js.map +1 -1
  19. package/dist/src/components/For.d.ts +44 -0
  20. package/dist/src/components/For.d.ts.map +1 -0
  21. package/dist/src/components/For.js +41 -0
  22. package/dist/src/components/For.js.map +1 -0
  23. package/dist/src/components/Indent.d.ts +6 -10
  24. package/dist/src/components/Indent.d.ts.map +1 -1
  25. package/dist/src/components/Indent.js +7 -18
  26. package/dist/src/components/Indent.js.map +1 -1
  27. package/dist/src/components/List.d.ts +38 -0
  28. package/dist/src/components/List.d.ts.map +1 -0
  29. package/dist/src/components/List.js +40 -0
  30. package/dist/src/components/List.js.map +1 -0
  31. package/dist/src/components/MemberDeclaration.d.ts +1 -1
  32. package/dist/src/components/MemberDeclaration.d.ts.map +1 -1
  33. package/dist/src/components/MemberDeclaration.js.map +1 -1
  34. package/dist/src/components/MemberName.d.ts +1 -1
  35. package/dist/src/components/MemberName.d.ts.map +1 -1
  36. package/dist/src/components/MemberName.js +1 -1
  37. package/dist/src/components/MemberName.js.map +1 -1
  38. package/dist/src/components/MemberScope.d.ts +1 -1
  39. package/dist/src/components/MemberScope.d.ts.map +1 -1
  40. package/dist/src/components/MemberScope.js.map +1 -1
  41. package/dist/src/components/Name.d.ts +1 -1
  42. package/dist/src/components/Name.d.ts.map +1 -1
  43. package/dist/src/components/Name.js +1 -1
  44. package/dist/src/components/Name.js.map +1 -1
  45. package/dist/src/components/Output.d.ts +3 -2
  46. package/dist/src/components/Output.d.ts.map +1 -1
  47. package/dist/src/components/Output.js +12 -2
  48. package/dist/src/components/Output.js.map +1 -1
  49. package/dist/src/components/Scope.d.ts +1 -1
  50. package/dist/src/components/Scope.d.ts.map +1 -1
  51. package/dist/src/components/Scope.js.map +1 -1
  52. package/dist/src/components/Show.d.ts +8 -0
  53. package/dist/src/components/Show.d.ts.map +1 -0
  54. package/dist/src/components/Show.js +4 -0
  55. package/dist/src/components/Show.js.map +1 -0
  56. package/dist/src/components/SourceDirectory.d.ts +2 -2
  57. package/dist/src/components/SourceDirectory.d.ts.map +1 -1
  58. package/dist/src/components/SourceDirectory.js +1 -0
  59. package/dist/src/components/SourceDirectory.js.map +1 -1
  60. package/dist/src/components/SourceFile.d.ts +4 -8
  61. package/dist/src/components/SourceFile.d.ts.map +1 -1
  62. package/dist/src/components/SourceFile.js +6 -13
  63. package/dist/src/components/SourceFile.js.map +1 -1
  64. package/dist/src/components/StatementList.d.ts +9 -0
  65. package/dist/src/components/StatementList.d.ts.map +1 -0
  66. package/dist/src/components/StatementList.js +17 -0
  67. package/dist/src/components/StatementList.js.map +1 -0
  68. package/dist/src/components/Switch.d.ts +41 -0
  69. package/dist/src/components/Switch.d.ts.map +1 -0
  70. package/dist/src/components/Switch.js +41 -0
  71. package/dist/src/components/Switch.js.map +1 -0
  72. package/dist/src/components/Wrap.d.ts +20 -0
  73. package/dist/src/components/Wrap.d.ts.map +1 -0
  74. package/dist/src/components/Wrap.js +15 -0
  75. package/dist/src/components/Wrap.js.map +1 -0
  76. package/dist/src/components/index.d.ts +8 -1
  77. package/dist/src/components/index.d.ts.map +1 -1
  78. package/dist/src/components/index.js +7 -0
  79. package/dist/src/components/index.js.map +1 -1
  80. package/dist/src/components/stc/index.d.ts +89 -18
  81. package/dist/src/components/stc/index.d.ts.map +1 -1
  82. package/dist/src/components/stc/index.js +17 -1
  83. package/dist/src/components/stc/index.js.map +1 -1
  84. package/dist/src/context/index.d.ts +0 -1
  85. package/dist/src/context/index.d.ts.map +1 -1
  86. package/dist/src/context/index.js +0 -1
  87. package/dist/src/context/index.js.map +1 -1
  88. package/dist/src/context/member-declaration.d.ts +1 -0
  89. package/dist/src/context/member-declaration.d.ts.map +1 -1
  90. package/dist/src/context/member-declaration.js +4 -1
  91. package/dist/src/context/member-declaration.js.map +1 -1
  92. package/dist/src/context.d.ts.map +1 -1
  93. package/dist/src/context.js +3 -3
  94. package/dist/src/context.js.map +1 -1
  95. package/dist/src/index.browser.d.ts +3 -0
  96. package/dist/src/index.browser.d.ts.map +1 -0
  97. package/dist/src/index.browser.js +3 -0
  98. package/dist/src/index.browser.js.map +1 -0
  99. package/dist/src/index.d.ts +2 -0
  100. package/dist/src/index.d.ts.map +1 -1
  101. package/dist/src/index.js +2 -0
  102. package/dist/src/index.js.map +1 -1
  103. package/dist/src/jsx-runtime.d.ts +151 -7
  104. package/dist/src/jsx-runtime.d.ts.map +1 -1
  105. package/dist/src/jsx-runtime.js +113 -12
  106. package/dist/src/jsx-runtime.js.map +1 -1
  107. package/dist/src/render.d.ts +107 -132
  108. package/dist/src/render.d.ts.map +1 -1
  109. package/dist/src/render.js +272 -178
  110. package/dist/src/render.js.map +1 -1
  111. package/dist/src/stc.d.ts +14 -0
  112. package/dist/src/stc.d.ts.map +1 -0
  113. package/dist/src/stc.js +52 -0
  114. package/dist/src/stc.js.map +1 -0
  115. package/dist/src/tap.d.ts +19 -0
  116. package/dist/src/tap.d.ts.map +1 -0
  117. package/dist/src/tap.js +39 -0
  118. package/dist/src/tap.js.map +1 -0
  119. package/dist/src/utils.d.ts +22 -15
  120. package/dist/src/utils.d.ts.map +1 -1
  121. package/dist/src/utils.js +95 -59
  122. package/dist/src/utils.js.map +1 -1
  123. package/dist/test/browser-build.test.d.ts +2 -0
  124. package/dist/test/browser-build.test.d.ts.map +1 -0
  125. package/dist/test/components/block.test.d.ts +2 -0
  126. package/dist/test/components/block.test.d.ts.map +1 -0
  127. package/dist/test/components/declaration.test.d.ts +2 -0
  128. package/dist/test/components/declaration.test.d.ts.map +1 -0
  129. package/dist/test/components/list.test.d.ts +2 -0
  130. package/dist/test/components/list.test.d.ts.map +1 -0
  131. package/dist/test/components/wrap.test.d.ts +2 -0
  132. package/dist/test/components/wrap.test.d.ts.map +1 -0
  133. package/dist/test/control-flow/for.test.d.ts +2 -0
  134. package/dist/test/control-flow/for.test.d.ts.map +1 -0
  135. package/dist/test/control-flow/match.test.d.ts +2 -0
  136. package/dist/test/control-flow/match.test.d.ts.map +1 -0
  137. package/dist/test/control-flow/show.test.d.ts +2 -0
  138. package/dist/test/control-flow/show.test.d.ts.map +1 -0
  139. package/dist/test/reactivity/cleanup.test.d.ts +2 -0
  140. package/dist/test/reactivity/cleanup.test.d.ts.map +1 -0
  141. package/dist/test/reactivity/memo.test.d.ts +2 -0
  142. package/dist/test/reactivity/memo.test.d.ts.map +1 -0
  143. package/dist/test/reactivity/untrack.test.d.ts +2 -0
  144. package/dist/test/reactivity/untrack.test.d.ts.map +1 -0
  145. package/dist/test/rendering/formatting.test.d.ts +2 -0
  146. package/dist/test/rendering/formatting.test.d.ts.map +1 -0
  147. package/dist/test/rendering/memoization.test.d.ts +2 -0
  148. package/dist/test/rendering/memoization.test.d.ts.map +1 -0
  149. package/dist/test/split-props.test.d.ts +2 -0
  150. package/dist/test/split-props.test.d.ts.map +1 -0
  151. package/dist/test/stc.test.d.ts.map +1 -1
  152. package/dist/test/utils.test.d.ts.map +1 -1
  153. package/dist/testing/extend-expect.js +4 -4
  154. package/dist/testing/extend-expect.js.map +1 -1
  155. package/dist/testing/render.d.ts +2 -3
  156. package/dist/testing/render.d.ts.map +1 -1
  157. package/dist/testing/render.js +2 -4
  158. package/dist/testing/render.js.map +1 -1
  159. package/dist/tsconfig.tsbuildinfo +1 -1
  160. package/package.json +8 -9
  161. package/src/binder.ts +60 -50
  162. package/src/code.ts +17 -12
  163. package/src/components/Block.tsx +44 -0
  164. package/src/components/Declaration.tsx +10 -4
  165. package/src/components/For.tsx +81 -0
  166. package/src/components/Indent.tsx +20 -27
  167. package/src/components/List.tsx +94 -0
  168. package/src/components/MemberDeclaration.tsx +9 -6
  169. package/src/components/MemberScope.tsx +4 -2
  170. package/src/components/Output.tsx +27 -14
  171. package/src/components/Scope.tsx +4 -2
  172. package/src/components/Show.tsx +11 -0
  173. package/src/components/SourceDirectory.tsx +6 -2
  174. package/src/components/SourceFile.tsx +13 -17
  175. package/src/components/StatementList.tsx +16 -0
  176. package/src/components/Switch.tsx +62 -0
  177. package/src/components/Wrap.tsx +29 -0
  178. package/src/components/index.tsx +8 -1
  179. package/src/components/stc/index.ts +18 -1
  180. package/src/context/index.ts +0 -1
  181. package/src/context/member-declaration.ts +9 -1
  182. package/src/context.ts +2 -3
  183. package/src/index.browser.ts +2 -0
  184. package/src/index.ts +2 -0
  185. package/src/jsx-runtime.ts +265 -23
  186. package/src/render.ts +382 -200
  187. package/src/stc.ts +95 -0
  188. package/src/tap.ts +69 -0
  189. package/src/utils.ts +162 -95
  190. package/temp/api.json +8042 -1886
  191. package/test/browser-build.test.ts +91 -0
  192. package/test/children.test.tsx +8 -10
  193. package/test/components/block.test.tsx +48 -0
  194. package/test/components/declaration.test.tsx +37 -0
  195. package/test/components/list.test.tsx +91 -0
  196. package/test/components/slot.test.tsx +31 -25
  197. package/test/components/source-file.test.tsx +11 -31
  198. package/test/components/wrap.test.tsx +42 -0
  199. package/test/control-flow/for.test.tsx +194 -0
  200. package/test/control-flow/match.test.tsx +49 -0
  201. package/test/control-flow/show.test.tsx +25 -0
  202. package/test/name-policy.test.tsx +5 -5
  203. package/test/reactivity/cleanup.test.tsx +91 -0
  204. package/test/reactivity/memo.test.tsx +17 -0
  205. package/test/reactivity/ref-rendering.test.tsx +3 -8
  206. package/test/reactivity/test.test.tsx +7 -6
  207. package/test/reactivity/untrack.test.ts +33 -0
  208. package/test/rendering/basic.test.tsx +25 -47
  209. package/test/rendering/code.test.tsx +3 -3
  210. package/test/rendering/formatting.test.tsx +487 -0
  211. package/test/rendering/indent.test.tsx +42 -529
  212. package/test/rendering/memoization.test.tsx +30 -0
  213. package/test/split-props.test.ts +87 -0
  214. package/test/stc.test.tsx +29 -8
  215. package/test/symbols.test.ts +132 -3
  216. package/test/utils.test.tsx +129 -20
  217. package/testing/extend-expect.ts +14 -4
  218. package/testing/render.ts +2 -4
  219. package/testing/vitest.d.ts +6 -1
  220. package/vitest.config.ts +1 -1
  221. package/dist/src/context/indent.d.ts +0 -5
  222. package/dist/src/context/indent.d.ts.map +0 -1
  223. package/dist/src/context/indent.js +0 -8
  224. package/dist/src/context/indent.js.map +0 -1
  225. package/dist/test/rendering/linebreaks.test.d.ts +0 -2
  226. package/dist/test/rendering/linebreaks.test.d.ts.map +0 -1
  227. package/src/context/indent.ts +0 -17
  228. package/test/rendering/linebreaks.test.tsx +0 -72
@@ -0,0 +1,487 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { For, Output, render, SourceFile } from "../../src/index.js";
3
+ import "../../testing/extend-expect.js";
4
+ import { d } from "../../testing/render.js";
5
+
6
+ describe("group", () => {
7
+ it("breaks when shouldBreak is passed", () => {
8
+ expect(
9
+ <group shouldBreak>
10
+ hi
11
+ <sbr />
12
+ bye
13
+ </group>,
14
+ ).toRenderTo(
15
+ `
16
+ hi
17
+ bye
18
+ `,
19
+ );
20
+ });
21
+ });
22
+ describe("indent", () => {
23
+ it("indents its children", () => {
24
+ expect(
25
+ <>
26
+ a
27
+ <indent>
28
+ <hardline />b
29
+ </indent>
30
+ </>,
31
+ ).toRenderTo(`
32
+ a
33
+ b
34
+ `);
35
+ });
36
+ });
37
+
38
+ describe("dedent and markAsRoot", () => {
39
+ it("dedents its children", () => {
40
+ expect(
41
+ <>
42
+ base
43
+ <indent>
44
+ <hbr />a
45
+ <dedent>
46
+ <hardline />b
47
+ </dedent>
48
+ </indent>
49
+ </>,
50
+ ).toRenderTo(`
51
+ base
52
+ a
53
+ b
54
+ `);
55
+ });
56
+ });
57
+
58
+ describe("dedentToRoot and setRoot", () => {
59
+ it("dedents to the indent level marked by the root when not marked", () => {
60
+ expect(
61
+ <>
62
+ base
63
+ <indent>
64
+ <hbr />a
65
+ <dedentToRoot>
66
+ <hbr />b
67
+ </dedentToRoot>
68
+ </indent>
69
+ </>,
70
+ ).toRenderTo(`
71
+ base
72
+ a
73
+ b
74
+ `);
75
+ });
76
+ it("dedents to the indent level marked by the root when marked", () => {
77
+ expect(
78
+ <>
79
+ base
80
+ <indent>
81
+ <hbr />
82
+ root
83
+ <markAsRoot>
84
+ <indent>
85
+ <hbr />a
86
+ <dedentToRoot>
87
+ <hbr />b
88
+ </dedentToRoot>
89
+ </indent>
90
+ </markAsRoot>
91
+ </indent>
92
+ </>,
93
+ ).toRenderTo(`
94
+ base
95
+ root
96
+ a
97
+ b
98
+ `);
99
+ });
100
+ });
101
+
102
+ describe("softline", () => {
103
+ it("breaks to to a new line when needed", () => {
104
+ expect(
105
+ <group>
106
+ 1234567890
107
+ <softline />
108
+ 1234567890
109
+ </group>,
110
+ ).toRenderTo(`12345678901234567890`, { printWidth: 25 });
111
+ expect(
112
+ <group>
113
+ 1234567890
114
+ <softline />
115
+ 1234567890
116
+ </group>,
117
+ ).toRenderTo(
118
+ `
119
+ 1234567890
120
+ 1234567890
121
+ `,
122
+ { printWidth: 15 },
123
+ );
124
+ expect(
125
+ <group>
126
+ 1234567890
127
+ <sbr />
128
+ 1234567890
129
+ </group>,
130
+ ).toRenderTo(`12345678901234567890`, { printWidth: 25 });
131
+ expect(
132
+ <group>
133
+ 1234567890
134
+ <sbr />
135
+ 1234567890
136
+ </group>,
137
+ ).toRenderTo(
138
+ `
139
+ 1234567890
140
+ 1234567890
141
+ `,
142
+ { printWidth: 15 },
143
+ );
144
+ });
145
+ });
146
+
147
+ describe("hardline", () => {
148
+ it("always breaks to a new line", () => {
149
+ expect(
150
+ <group>
151
+ 1234567890
152
+ <hardline />
153
+ 1234567890
154
+ </group>,
155
+ ).toRenderTo(
156
+ `
157
+ 1234567890
158
+ 1234567890
159
+ `,
160
+ );
161
+ expect(
162
+ <group>
163
+ 1234567890
164
+ <hbr />
165
+ 1234567890
166
+ </group>,
167
+ ).toRenderTo(
168
+ `
169
+ 1234567890
170
+ 1234567890
171
+ `,
172
+ );
173
+ });
174
+ });
175
+
176
+ describe("line", () => {
177
+ it("creates a new line when needed, is otherwise space", () => {
178
+ expect(
179
+ <group>
180
+ 1234567890
181
+ <line />
182
+ 1234567890
183
+ </group>,
184
+ ).toRenderTo(`1234567890 1234567890`, { printWidth: 25 });
185
+ expect(
186
+ <group>
187
+ 1234567890
188
+ <line />
189
+ 1234567890
190
+ </group>,
191
+ ).toRenderTo(
192
+ `
193
+ 1234567890
194
+ 1234567890
195
+ `,
196
+ { printWidth: 15 },
197
+ );
198
+ expect(
199
+ <group>
200
+ 1234567890
201
+ <br />
202
+ 1234567890
203
+ </group>,
204
+ ).toRenderTo(`1234567890 1234567890`, { printWidth: 25 });
205
+ expect(
206
+ <group>
207
+ 1234567890
208
+ <br />
209
+ 1234567890
210
+ </group>,
211
+ ).toRenderTo(
212
+ `
213
+ 1234567890
214
+ 1234567890
215
+ `,
216
+ { printWidth: 15 },
217
+ );
218
+ });
219
+ });
220
+
221
+ describe("literalline", () => {
222
+ it("always creates a new line", () => {
223
+ expect(
224
+ <>
225
+ base
226
+ <indent>
227
+ <hbr />
228
+ 1234567890
229
+ <literalline />
230
+ 1234567890
231
+ <hbr />x
232
+ </indent>
233
+ </>,
234
+ ).toRenderTo(
235
+ `
236
+ base
237
+ 1234567890
238
+ 1234567890
239
+ x
240
+ `,
241
+ );
242
+ expect(
243
+ <>
244
+ base
245
+ <indent>
246
+ <hbr />
247
+ 1234567890
248
+ <lbr />
249
+ 1234567890
250
+ <hbr />x
251
+ </indent>
252
+ </>,
253
+ ).toRenderTo(
254
+ `
255
+ base
256
+ 1234567890
257
+ 1234567890
258
+ x
259
+ `,
260
+ );
261
+ });
262
+ });
263
+
264
+ describe("lineSuffix and lineSuffixBoundary", () => {
265
+ it("adds a line suffix", () => {
266
+ expect(
267
+ <>
268
+ hello<lineSuffix>// comment</lineSuffix> there
269
+ <hbr />
270
+ how<lineSuffix>// another comment</lineSuffix> are{" "}
271
+ <lineSuffixBoundary />
272
+ you
273
+ </>,
274
+ ).toRenderTo(
275
+ `
276
+ hello there// comment
277
+ how are // another comment
278
+ you
279
+ `,
280
+ );
281
+ });
282
+ });
283
+
284
+ describe("breakParent", () => {
285
+ it("breaks the parent group", () => {
286
+ expect(
287
+ <group>
288
+ <breakParent />
289
+ one
290
+ <sbr />
291
+ two
292
+ </group>,
293
+ ).toRenderTo(
294
+ `
295
+ one
296
+ two
297
+ `,
298
+ );
299
+ });
300
+ });
301
+
302
+ describe("ifBreak", () => {
303
+ it("renders the children when broken", () => {
304
+ expect(
305
+ <group>
306
+ <ifBreak flatContents="bye">hi</ifBreak>
307
+ </group>,
308
+ ).toRenderTo(`bye`);
309
+ });
310
+
311
+ it("renders the children when not broken", () => {
312
+ expect(
313
+ <group>
314
+ <ifBreak flatContents="bye">hi</ifBreak>
315
+ <breakParent />
316
+ </group>,
317
+ ).toRenderTo(`hi`);
318
+ });
319
+
320
+ it("renders flatContents that are elements", () => {
321
+ function Foo() {
322
+ return "Foo";
323
+ }
324
+ const contents = (
325
+ <>
326
+ <Foo />
327
+ <Foo />
328
+ </>
329
+ );
330
+
331
+ expect(
332
+ <group>
333
+ <ifBreak flatContents={contents}>hi</ifBreak>
334
+ </group>,
335
+ ).toRenderTo(`FooFoo`);
336
+ });
337
+
338
+ it("works with a group id", () => {
339
+ const id = Symbol();
340
+ expect(
341
+ <>
342
+ <group id={id}>
343
+ a<hbr />b<hbr />
344
+ </group>
345
+ <ifBreak groupId={id}>c</ifBreak>
346
+ </>,
347
+ ).toRenderTo(`a\nb\nc`);
348
+ });
349
+ });
350
+
351
+ describe("fill", () => {
352
+ it("fills the group with its children", () => {
353
+ const items = ["one", "two", "three", "four", "five", "six"];
354
+ // place a <br /> after every item except the last
355
+ const filledItems = items.map((item, index) => (
356
+ <>
357
+ {item}
358
+ {index < items.length - 1 && <br />}
359
+ </>
360
+ ));
361
+
362
+ expect(<fill>{filledItems}</fill>).toRenderTo(
363
+ `one two three four\nfive six`,
364
+ { printWidth: 20 },
365
+ );
366
+ });
367
+ });
368
+
369
+ describe("align", () => {
370
+ it("aligns contents with a number of spaces", () => {
371
+ expect(
372
+ <>
373
+ base
374
+ <align width={4}>
375
+ <hbr />
376
+ hi
377
+ </align>
378
+ </>,
379
+ ).toRenderTo(
380
+ `
381
+ base
382
+ hi
383
+ `,
384
+ );
385
+ });
386
+
387
+ it("aligns contents with a string", () => {
388
+ expect(
389
+ <>
390
+ base
391
+ <align string="XXXX">
392
+ <hbr />
393
+ hi
394
+ </align>
395
+ </>,
396
+ ).toRenderTo(
397
+ `
398
+ base
399
+ XXXXhi
400
+ `,
401
+ );
402
+ });
403
+ });
404
+
405
+ it("all works together", () => {
406
+ const argCount = 2;
407
+ const args = Array.from({ length: argCount }, (_, i) => `arg${i + 1}`);
408
+ expect(
409
+ <>
410
+ <group>
411
+ async function foo(
412
+ <indent>
413
+ <sbr />
414
+ <For
415
+ each={args}
416
+ joiner={
417
+ <>
418
+ ,<br />
419
+ </>
420
+ }
421
+ >
422
+ {(arg) => <>{arg}: string</>}
423
+ </For>
424
+ </indent>
425
+ <sbr />)
426
+ </group>
427
+ : void {"{"}
428
+ <indent>
429
+ <hbr />
430
+ // function body
431
+ </indent>
432
+ <hbr />
433
+ {"}"}
434
+ </>,
435
+ ).toRenderTo(
436
+ `
437
+ async function foo(arg1: string, arg2: string): void {
438
+ // function body
439
+ }
440
+ `,
441
+ { printWidth: 80 },
442
+ );
443
+ });
444
+
445
+ it("formats based on the output component props", () => {
446
+ const template = (
447
+ <Output printWidth={5}>
448
+ <SourceFile path="foo.txt" filetype="text/plain">
449
+ <group>
450
+ 1<br />2<br />3<br />4<br />5<br />6
451
+ </group>
452
+ </SourceFile>
453
+ </Output>
454
+ );
455
+
456
+ const tree = render(template);
457
+ expect(tree.contents[0].contents).toEqual(d`
458
+ 1
459
+ 2
460
+ 3
461
+ 4
462
+ 5
463
+ 6
464
+ `);
465
+ });
466
+
467
+ it("formats based on the source file component props", () => {
468
+ const template = (
469
+ <Output>
470
+ <SourceFile path="foo.txt" filetype="text/plain" printWidth={5}>
471
+ <group>
472
+ 1<br />2<br />3<br />4<br />5<br />6
473
+ </group>
474
+ </SourceFile>
475
+ </Output>
476
+ );
477
+
478
+ const tree = render(template);
479
+ expect(tree.contents[0].contents).toEqual(d`
480
+ 1
481
+ 2
482
+ 3
483
+ 4
484
+ 5
485
+ 6
486
+ `);
487
+ });