@typespec/emitter-framework 0.9.0-dev.7 → 0.9.0-dev.9

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 (60) hide show
  1. package/dist/src/csharp/components/class/declaration.test.js +100 -115
  2. package/dist/src/csharp/components/{enum-declaration.d.ts → enum/declaration.d.ts} +1 -1
  3. package/dist/src/csharp/components/enum/declaration.d.ts.map +1 -0
  4. package/dist/src/csharp/components/{enum-declaration.js → enum/declaration.js} +4 -4
  5. package/dist/src/csharp/components/enum/declaration.test.d.ts +2 -0
  6. package/dist/src/csharp/components/enum/declaration.test.d.ts.map +1 -0
  7. package/dist/src/csharp/components/enum/declaration.test.js +309 -0
  8. package/dist/src/csharp/components/index.d.ts +1 -1
  9. package/dist/src/csharp/components/index.js +1 -1
  10. package/dist/src/csharp/components/property/property.test.js +14 -14
  11. package/dist/src/testing/scenario-test/code-block-expectation.d.ts +33 -0
  12. package/dist/src/testing/scenario-test/code-block-expectation.d.ts.map +1 -0
  13. package/dist/src/testing/scenario-test/code-block-expectation.js +69 -0
  14. package/dist/src/testing/scenario-test/code-block-expectation.test.d.ts +2 -0
  15. package/dist/src/testing/scenario-test/code-block-expectation.test.d.ts.map +1 -0
  16. package/dist/src/testing/scenario-test/code-block-expectation.test.js +80 -0
  17. package/dist/src/testing/scenario-test/harness.d.ts +2 -2
  18. package/dist/src/testing/scenario-test/harness.d.ts.map +1 -1
  19. package/dist/src/testing/scenario-test/harness.js +69 -158
  20. package/dist/src/testing/scenario-test/index.d.ts +0 -1
  21. package/dist/src/testing/scenario-test/index.d.ts.map +1 -1
  22. package/dist/src/testing/scenario-test/index.js +1 -2
  23. package/dist/src/testing/scenario-test/snippet-extractor.d.ts +1 -1
  24. package/dist/src/testing/scenario-test/snippet-extractor.js +1 -1
  25. package/dist/test/testing/snippet-extractor-csharp.test.js +3 -3
  26. package/dist/test/testing/snippet-extractor-java.test.js +3 -3
  27. package/dist/test/testing/snippet-extractor-python.test.js +2 -2
  28. package/dist/test/testing/snippet-extractor-typescript.test.js +3 -3
  29. package/package.json +8 -6
  30. package/src/csharp/components/class/declaration.test.tsx +106 -168
  31. package/src/csharp/components/enum/declaration.test.tsx +267 -0
  32. package/src/csharp/components/{enum-declaration.tsx → enum/declaration.tsx} +4 -4
  33. package/src/csharp/components/index.ts +1 -1
  34. package/src/csharp/components/property/property.test.tsx +14 -14
  35. package/src/testing/scenario-test/code-block-expectation.test.ts +95 -0
  36. package/src/testing/scenario-test/code-block-expectation.ts +115 -0
  37. package/src/testing/scenario-test/harness.ts +91 -236
  38. package/src/testing/scenario-test/index.ts +0 -1
  39. package/src/testing/scenario-test/snippet-extractor.ts +1 -1
  40. package/test/testing/snippet-extractor-csharp.test.ts +3 -3
  41. package/test/testing/snippet-extractor-java.test.ts +3 -3
  42. package/test/testing/snippet-extractor-python.test.ts +2 -2
  43. package/test/testing/snippet-extractor-typescript.test.ts +3 -3
  44. package/dist/src/csharp/components/enum-declaration.d.ts.map +0 -1
  45. package/dist/src/testing/scenario-test/test-host.d.ts +0 -8
  46. package/dist/src/testing/scenario-test/test-host.d.ts.map +0 -1
  47. package/dist/src/testing/scenario-test/test-host.js +0 -49
  48. package/dist/test/csharp/components/enum-declaration.test.d.ts +0 -2
  49. package/dist/test/csharp/components/enum-declaration.test.d.ts.map +0 -1
  50. package/dist/test/csharp/components/enum-declaration.test.js +0 -403
  51. package/dist/test/csharp/test-host.d.ts +0 -11
  52. package/dist/test/csharp/test-host.d.ts.map +0 -1
  53. package/dist/test/csharp/test-host.js +0 -32
  54. package/dist/test/csharp/utils.d.ts +0 -3
  55. package/dist/test/csharp/utils.d.ts.map +0 -1
  56. package/dist/test/csharp/utils.js +0 -6
  57. package/src/testing/scenario-test/test-host.ts +0 -83
  58. package/test/csharp/components/enum-declaration.test.tsx +0 -337
  59. package/test/csharp/test-host.ts +0 -42
  60. package/test/csharp/utils.ts +0 -8
@@ -1,11 +1,8 @@
1
1
  import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
2
2
  import { Tester } from "#test/test-host.js";
3
- import { render } from "@alloy-js/core";
4
- import { d } from "@alloy-js/core/testing";
5
3
  import { createCSharpNamePolicy, Namespace, SourceFile } from "@alloy-js/csharp";
6
4
  import { t } from "@typespec/compiler/testing";
7
- import { beforeEach, describe, it } from "vitest";
8
- import { assertFileContents } from "../../../../test/csharp/utils.js";
5
+ import { beforeEach, describe, expect, it } from "vitest";
9
6
  import { Output } from "../../../core/index.js";
10
7
  import { ClassDeclaration, EnumDeclaration } from "../../index.js";
11
8
  let runner;
@@ -40,22 +37,21 @@ it("renders an empty class declaration", async () => {
40
37
  } = await runner.compile(t.code`
41
38
  model ${t.model("TestModel")} {}
42
39
  `);
43
- const res = render(_$createComponent(Wrapper, {
40
+ expect(_$createComponent(Wrapper, {
44
41
  get children() {
45
42
  return _$createComponent(ClassDeclaration, {
46
43
  type: TestModel
47
44
  });
48
45
  }
49
- }));
50
- assertFileContents(res, d`
51
- namespace TestNamespace
52
- {
53
- class TestModel
54
- {
46
+ })).toRenderTo(`
47
+ namespace TestNamespace
48
+ {
49
+ class TestModel
50
+ {
55
51
 
56
- }
57
- }
58
- `);
52
+ }
53
+ }
54
+ `);
59
55
  });
60
56
  it("renders a class declaration with properties", async () => {
61
57
  const {
@@ -66,23 +62,22 @@ it("renders a class declaration with properties", async () => {
66
62
  @test Prop2: int32;
67
63
  }
68
64
  `);
69
- const res = render(_$createComponent(Wrapper, {
65
+ expect(_$createComponent(Wrapper, {
70
66
  get children() {
71
67
  return _$createComponent(ClassDeclaration, {
72
68
  type: TestModel
73
69
  });
74
70
  }
75
- }));
76
- assertFileContents(res, d`
77
- namespace TestNamespace
78
- {
79
- class TestModel
80
- {
81
- public required string Prop1 { get; set; }
82
- public required int Prop2 { get; set; }
83
- }
84
- }
85
- `);
71
+ })).toRenderTo(`
72
+ namespace TestNamespace
73
+ {
74
+ class TestModel
75
+ {
76
+ public required string Prop1 { get; set; }
77
+ public required int Prop2 { get; set; }
78
+ }
79
+ }
80
+ `);
86
81
  });
87
82
  it("can override class name", async () => {
88
83
  const {
@@ -90,23 +85,22 @@ it("can override class name", async () => {
90
85
  } = await runner.compile(t.code`
91
86
  model ${t.model("TestModel")} {}
92
87
  `);
93
- const res = render(_$createComponent(Wrapper, {
88
+ expect(_$createComponent(Wrapper, {
94
89
  get children() {
95
90
  return _$createComponent(ClassDeclaration, {
96
91
  type: TestModel,
97
92
  name: "CustomClassName"
98
93
  });
99
94
  }
100
- }));
101
- assertFileContents(res, d`
102
- namespace TestNamespace
103
- {
104
- class CustomClassName
105
- {
95
+ })).toRenderTo(`
96
+ namespace TestNamespace
97
+ {
98
+ class CustomClassName
99
+ {
106
100
 
107
- }
108
- }
109
- `);
101
+ }
102
+ }
103
+ `);
110
104
  });
111
105
  it("renders a class with access modifiers", async () => {
112
106
  const {
@@ -115,23 +109,22 @@ it("renders a class with access modifiers", async () => {
115
109
  model ${t.model("TestModel")} {
116
110
  }
117
111
  `);
118
- const res = render(_$createComponent(Wrapper, {
112
+ expect(_$createComponent(Wrapper, {
119
113
  get children() {
120
114
  return _$createComponent(ClassDeclaration, {
121
115
  type: TestModel,
122
116
  "protected": true
123
117
  });
124
118
  }
125
- }));
126
- assertFileContents(res, d`
127
- namespace TestNamespace
128
- {
129
- protected class TestModel
130
- {
119
+ })).toRenderTo(`
120
+ namespace TestNamespace
121
+ {
122
+ protected class TestModel
123
+ {
131
124
 
132
- }
133
- }
134
- `);
125
+ }
126
+ }
127
+ `);
135
128
  });
136
129
  describe("from an interface", () => {
137
130
  it("renders an empty class", async () => {
@@ -141,14 +134,13 @@ describe("from an interface", () => {
141
134
  interface ${t.interface("TestInterface")} {
142
135
  }
143
136
  `);
144
- const res = render(_$createComponent(Wrapper, {
137
+ expect(_$createComponent(Wrapper, {
145
138
  get children() {
146
139
  return _$createComponent(ClassDeclaration, {
147
140
  type: TestInterface
148
141
  });
149
142
  }
150
- }));
151
- assertFileContents(res, d`
143
+ })).toRenderTo(`
152
144
  namespace TestNamespace
153
145
  {
154
146
  class TestInterface
@@ -166,14 +158,13 @@ describe("from an interface", () => {
166
158
  op getName(id: string): string;
167
159
  }
168
160
  `);
169
- const res = render(_$createComponent(Wrapper, {
161
+ expect(_$createComponent(Wrapper, {
170
162
  get children() {
171
163
  return _$createComponent(ClassDeclaration, {
172
164
  type: TestInterface
173
165
  });
174
166
  }
175
- }));
176
- assertFileContents(res, d`
167
+ })).toRenderTo(`
177
168
  namespace TestNamespace
178
169
  {
179
170
  class TestInterface
@@ -194,7 +185,7 @@ it("renders a class with model members", async () => {
194
185
  prop1: TestReference;
195
186
  }
196
187
  `);
197
- const res = render(_$createComponent(Wrapper, {
188
+ expect(_$createComponent(Wrapper, {
198
189
  get children() {
199
190
  return [_$createComponent(ClassDeclaration, {
200
191
  type: TestReference
@@ -202,20 +193,19 @@ it("renders a class with model members", async () => {
202
193
  type: TestModel
203
194
  })];
204
195
  }
205
- }));
206
- assertFileContents(res, d`
207
- namespace TestNamespace
208
- {
209
- class TestReference
210
- {
196
+ })).toRenderTo(`
197
+ namespace TestNamespace
198
+ {
199
+ class TestReference
200
+ {
211
201
 
212
- }
213
- class TestModel
214
- {
215
- public required TestReference Prop1 { get; set; }
216
- }
217
- }
218
- `);
202
+ }
203
+ class TestModel
204
+ {
205
+ public required TestReference Prop1 { get; set; }
206
+ }
207
+ }
208
+ `);
219
209
  });
220
210
  it("renders a class with enum members", async () => {
221
211
  const {
@@ -230,7 +220,7 @@ it("renders a class with enum members", async () => {
230
220
  @test prop1: TestEnum;
231
221
  }
232
222
  `);
233
- const res = render(_$createComponent(Wrapper, {
223
+ expect(_$createComponent(Wrapper, {
234
224
  get children() {
235
225
  return [_$createComponent(EnumDeclaration, {
236
226
  type: TestEnum
@@ -238,21 +228,20 @@ it("renders a class with enum members", async () => {
238
228
  type: TestModel
239
229
  })];
240
230
  }
241
- }));
242
- assertFileContents(res, d`
243
- namespace TestNamespace
244
- {
245
- enum TestEnum
246
- {
247
- Value1,
248
- Value2
249
- }
250
- class TestModel
251
- {
252
- public required TestEnum Prop1 { get; set; }
253
- }
254
- }
255
- `);
231
+ })).toRenderTo(`
232
+ namespace TestNamespace
233
+ {
234
+ enum TestEnum
235
+ {
236
+ Value1,
237
+ Value2
238
+ }
239
+ class TestModel
240
+ {
241
+ public required TestEnum Prop1 { get; set; }
242
+ }
243
+ }
244
+ `);
256
245
  });
257
246
  it("maps prop: string | null to nullable property", async () => {
258
247
  const {
@@ -262,22 +251,21 @@ it("maps prop: string | null to nullable property", async () => {
262
251
  prop1: string | null;
263
252
  }
264
253
  `);
265
- const res = render(_$createComponent(Wrapper, {
254
+ expect(_$createComponent(Wrapper, {
266
255
  get children() {
267
256
  return _$createComponent(ClassDeclaration, {
268
257
  type: TestModel
269
258
  });
270
259
  }
271
- }));
272
- assertFileContents(res, d`
273
- namespace TestNamespace
274
- {
275
- class TestModel
276
- {
277
- public required string? Prop1 { get; set; }
278
- }
279
- }
280
- `);
260
+ })).toRenderTo(`
261
+ namespace TestNamespace
262
+ {
263
+ class TestModel
264
+ {
265
+ public required string? Prop1 { get; set; }
266
+ }
267
+ }
268
+ `);
281
269
  });
282
270
  it("renders a class with string enums", async () => {
283
271
  const {
@@ -292,7 +280,7 @@ it("renders a class with string enums", async () => {
292
280
  @test prop1: TestEnum;
293
281
  }
294
282
  `);
295
- const res = render(_$createComponent(Wrapper, {
283
+ expect(_$createComponent(Wrapper, {
296
284
  get children() {
297
285
  return [_$createComponent(EnumDeclaration, {
298
286
  type: TestEnum
@@ -300,21 +288,20 @@ it("renders a class with string enums", async () => {
300
288
  type: TestModel
301
289
  })];
302
290
  }
303
- }));
304
- assertFileContents(res, d`
305
- namespace TestNamespace
306
- {
307
- enum TestEnum
308
- {
309
- Value1,
310
- Value2
311
- }
312
- class TestModel
313
- {
314
- public required TestEnum Prop1 { get; set; }
315
- }
316
- }
317
- `);
291
+ })).toRenderTo(`
292
+ namespace TestNamespace
293
+ {
294
+ enum TestEnum
295
+ {
296
+ Value1,
297
+ Value2
298
+ }
299
+ class TestModel
300
+ {
301
+ public required TestEnum Prop1 { get; set; }
302
+ }
303
+ }
304
+ `);
318
305
  });
319
306
  describe("with doc comments", () => {
320
307
  it("renders a model with docs", async () => {
@@ -328,14 +315,13 @@ describe("with doc comments", () => {
328
315
  }
329
316
 
330
317
  `);
331
- const res = render(_$createComponent(Wrapper, {
318
+ expect(_$createComponent(Wrapper, {
332
319
  get children() {
333
320
  return _$createComponent(ClassDeclaration, {
334
321
  type: TestModel
335
322
  });
336
323
  }
337
- }));
338
- assertFileContents(res, d`
324
+ })).toRenderTo(`
339
325
  namespace TestNamespace
340
326
  {
341
327
  /// <summary>
@@ -362,14 +348,13 @@ describe("with doc comments", () => {
362
348
  op getName(id: string): string;
363
349
  }
364
350
  `);
365
- const res = render(_$createComponent(Wrapper, {
351
+ expect(_$createComponent(Wrapper, {
366
352
  get children() {
367
353
  return _$createComponent(ClassDeclaration, {
368
354
  type: TestInterface
369
355
  });
370
356
  }
371
- }));
372
- assertFileContents(res, d`
357
+ })).toRenderTo(`
373
358
  namespace TestNamespace
374
359
  {
375
360
  /// <summary>
@@ -6,4 +6,4 @@ export interface EnumDeclarationProps extends Omit<cs.EnumDeclarationProps, "nam
6
6
  type: Union | Enum;
7
7
  }
8
8
  export declare function EnumDeclaration(props: EnumDeclarationProps): Children;
9
- //# sourceMappingURL=enum-declaration.d.ts.map
9
+ //# sourceMappingURL=declaration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declaration.d.ts","sourceRoot":"","sources":["../../../../../src/csharp/components/enum/declaration.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,QAAQ,EAAO,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAKtD,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAAC,EAAE,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACjF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,KAAK,GAAG,IAAI,CAAC;CACpB;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,QAAQ,CA0CrE"}
@@ -1,10 +1,10 @@
1
1
  import { createComponent as _$createComponent, mergeProps as _$mergeProps, memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
+ import { useTsp } from "#core/context/tsp-context.js";
2
3
  import { For } from "@alloy-js/core";
3
4
  import * as cs from "@alloy-js/csharp";
4
- import { useTsp } from "../../core/index.js";
5
- import { reportDiagnostic } from "../../lib.js";
6
- import { getDocComments } from "./utils/doc-comments.js";
7
- import { declarationRefkeys, efRefkey } from "./utils/refkey.js";
5
+ import { reportDiagnostic } from "../../../lib.js";
6
+ import { getDocComments } from "../utils/doc-comments.js";
7
+ import { declarationRefkeys, efRefkey } from "../utils/refkey.js";
8
8
  export function EnumDeclaration(props) {
9
9
  const {
10
10
  $
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=declaration.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declaration.test.d.ts","sourceRoot":"","sources":["../../../../../src/csharp/components/enum/declaration.test.tsx"],"names":[],"mappings":""}