@typespec/emitter-framework 0.11.0-dev.7 → 0.11.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 (170) hide show
  1. package/dist/src/core/components/index.js +2 -1
  2. package/dist/src/core/components/index.js.map +1 -0
  3. package/dist/src/core/components/output.js +2 -1
  4. package/dist/src/core/components/output.js.map +1 -0
  5. package/dist/src/core/components/overrides/component-overrides.js +2 -1
  6. package/dist/src/core/components/overrides/component-overrides.js.map +1 -0
  7. package/dist/src/core/components/overrides/config.js +2 -1
  8. package/dist/src/core/components/overrides/config.js.map +1 -0
  9. package/dist/src/core/components/overrides/context.js +2 -1
  10. package/dist/src/core/components/overrides/context.js.map +1 -0
  11. package/dist/src/core/context/index.js +2 -1
  12. package/dist/src/core/context/index.js.map +1 -0
  13. package/dist/src/core/context/name-policy-context.js +2 -1
  14. package/dist/src/core/context/name-policy-context.js.map +1 -0
  15. package/dist/src/core/context/tsp-context.js +2 -1
  16. package/dist/src/core/context/tsp-context.js.map +1 -0
  17. package/dist/src/core/index.js +2 -1
  18. package/dist/src/core/index.js.map +1 -0
  19. package/dist/src/core/transport-name-policy.js +2 -1
  20. package/dist/src/core/transport-name-policy.js.map +1 -0
  21. package/dist/src/core/write-output.js +2 -1
  22. package/dist/src/core/write-output.js.map +1 -0
  23. package/dist/src/csharp/components/class/declaration.js +3 -2
  24. package/dist/src/csharp/components/class/declaration.js.map +1 -0
  25. package/dist/src/csharp/components/class/declaration.test.js +65 -105
  26. package/dist/src/csharp/components/class/declaration.test.js.map +1 -0
  27. package/dist/src/csharp/components/enum/declaration.js +2 -1
  28. package/dist/src/csharp/components/enum/declaration.js.map +1 -0
  29. package/dist/src/csharp/components/enum/declaration.test.js +52 -88
  30. package/dist/src/csharp/components/enum/declaration.test.js.map +1 -0
  31. package/dist/src/csharp/components/index.js +2 -1
  32. package/dist/src/csharp/components/index.js.map +1 -0
  33. package/dist/src/csharp/components/property/property.js +2 -1
  34. package/dist/src/csharp/components/property/property.js.map +1 -0
  35. package/dist/src/csharp/components/property/property.test.js +48 -73
  36. package/dist/src/csharp/components/property/property.test.js.map +1 -0
  37. package/dist/src/csharp/components/type-expression.js +2 -1
  38. package/dist/src/csharp/components/type-expression.js.map +1 -0
  39. package/dist/src/csharp/components/type-expression.test.js +46 -74
  40. package/dist/src/csharp/components/type-expression.test.js.map +1 -0
  41. package/dist/src/csharp/components/utils/doc-comments.js +2 -1
  42. package/dist/src/csharp/components/utils/doc-comments.js.map +1 -0
  43. package/dist/src/csharp/components/utils/nullable-util.js +2 -1
  44. package/dist/src/csharp/components/utils/nullable-util.js.map +1 -0
  45. package/dist/src/csharp/components/utils/refkey.js +2 -1
  46. package/dist/src/csharp/components/utils/refkey.js.map +1 -0
  47. package/dist/src/csharp/index.js +2 -1
  48. package/dist/src/csharp/index.js.map +1 -0
  49. package/dist/src/lib.js +2 -1
  50. package/dist/src/lib.js.map +1 -0
  51. package/dist/src/testing/index.js +2 -1
  52. package/dist/src/testing/index.js.map +1 -0
  53. package/dist/src/testing/scenario-test/code-block-expectation.js +2 -1
  54. package/dist/src/testing/scenario-test/code-block-expectation.js.map +1 -0
  55. package/dist/src/testing/scenario-test/code-block-expectation.test.js +2 -1
  56. package/dist/src/testing/scenario-test/code-block-expectation.test.js.map +1 -0
  57. package/dist/src/testing/scenario-test/harness.js +2 -1
  58. package/dist/src/testing/scenario-test/harness.js.map +1 -0
  59. package/dist/src/testing/scenario-test/index.js +2 -1
  60. package/dist/src/testing/scenario-test/index.js.map +1 -0
  61. package/dist/src/testing/scenario-test/snippet-extractor.js +2 -1
  62. package/dist/src/testing/scenario-test/snippet-extractor.js.map +1 -0
  63. package/dist/src/typescript/components/array-expression.js +2 -1
  64. package/dist/src/typescript/components/array-expression.js.map +1 -0
  65. package/dist/src/typescript/components/arrow-function.js +2 -1
  66. package/dist/src/typescript/components/arrow-function.js.map +1 -0
  67. package/dist/src/typescript/components/class-method.js +2 -1
  68. package/dist/src/typescript/components/class-method.js.map +1 -0
  69. package/dist/src/typescript/components/enum-declaration.js +2 -1
  70. package/dist/src/typescript/components/enum-declaration.js.map +1 -0
  71. package/dist/src/typescript/components/function-declaration.js +2 -1
  72. package/dist/src/typescript/components/function-declaration.js.map +1 -0
  73. package/dist/src/typescript/components/function-expression.js +2 -1
  74. package/dist/src/typescript/components/function-expression.js.map +1 -0
  75. package/dist/src/typescript/components/function-type.js +2 -1
  76. package/dist/src/typescript/components/function-type.js.map +1 -0
  77. package/dist/src/typescript/components/index.js +2 -1
  78. package/dist/src/typescript/components/index.js.map +1 -0
  79. package/dist/src/typescript/components/interface-declaration.js +2 -1
  80. package/dist/src/typescript/components/interface-declaration.js.map +1 -0
  81. package/dist/src/typescript/components/interface-member.js +2 -1
  82. package/dist/src/typescript/components/interface-member.js.map +1 -0
  83. package/dist/src/typescript/components/interface-method.js +2 -1
  84. package/dist/src/typescript/components/interface-method.js.map +1 -0
  85. package/dist/src/typescript/components/record-expression.js +2 -1
  86. package/dist/src/typescript/components/record-expression.js.map +1 -0
  87. package/dist/src/typescript/components/static-serializers.js +2 -1
  88. package/dist/src/typescript/components/static-serializers.js.map +1 -0
  89. package/dist/src/typescript/components/type-alias-declaration.js +2 -1
  90. package/dist/src/typescript/components/type-alias-declaration.js.map +1 -0
  91. package/dist/src/typescript/components/type-declaration.js +2 -1
  92. package/dist/src/typescript/components/type-declaration.js.map +1 -0
  93. package/dist/src/typescript/components/type-expression.js +2 -1
  94. package/dist/src/typescript/components/type-expression.js.map +1 -0
  95. package/dist/src/typescript/components/type-transform.js +2 -1
  96. package/dist/src/typescript/components/type-transform.js.map +1 -0
  97. package/dist/src/typescript/components/union/declaration.js +2 -1
  98. package/dist/src/typescript/components/union/declaration.js.map +1 -0
  99. package/dist/src/typescript/components/union/declaration.test.js +2 -1
  100. package/dist/src/typescript/components/union/declaration.test.js.map +1 -0
  101. package/dist/src/typescript/components/union/expression.js +2 -1
  102. package/dist/src/typescript/components/union/expression.js.map +1 -0
  103. package/dist/src/typescript/components/union/expression.test.js +2 -1
  104. package/dist/src/typescript/components/union/expression.test.js.map +1 -0
  105. package/dist/src/typescript/components/value-expression.js +2 -1
  106. package/dist/src/typescript/components/value-expression.js.map +1 -0
  107. package/dist/src/typescript/index.js +2 -1
  108. package/dist/src/typescript/index.js.map +1 -0
  109. package/dist/src/typescript/lib.js +2 -1
  110. package/dist/src/typescript/lib.js.map +1 -0
  111. package/dist/src/typescript/utils/index.js +2 -1
  112. package/dist/src/typescript/utils/index.js.map +1 -0
  113. package/dist/src/typescript/utils/operation.js +2 -1
  114. package/dist/src/typescript/utils/operation.js.map +1 -0
  115. package/dist/src/typescript/utils/refkey.js +2 -1
  116. package/dist/src/typescript/utils/refkey.js.map +1 -0
  117. package/dist/test/test-host.js +2 -1
  118. package/dist/test/test-host.js.map +1 -0
  119. package/dist/test/testing/snippet-extractor-csharp.test.js +2 -1
  120. package/dist/test/testing/snippet-extractor-csharp.test.js.map +1 -0
  121. package/dist/test/testing/snippet-extractor-java.test.js +2 -1
  122. package/dist/test/testing/snippet-extractor-java.test.js.map +1 -0
  123. package/dist/test/testing/snippet-extractor-python.test.js +2 -1
  124. package/dist/test/testing/snippet-extractor-python.test.js.map +1 -0
  125. package/dist/test/testing/snippet-extractor-typescript.test.js +2 -1
  126. package/dist/test/testing/snippet-extractor-typescript.test.js.map +1 -0
  127. package/dist/test/typescript/components/arrow-function.test.js +9 -14
  128. package/dist/test/typescript/components/arrow-function.test.js.map +1 -0
  129. package/dist/test/typescript/components/component-override.test.js +2 -1
  130. package/dist/test/typescript/components/component-override.test.js.map +1 -0
  131. package/dist/test/typescript/components/enum-declaration.test.js +2 -1
  132. package/dist/test/typescript/components/enum-declaration.test.js.map +1 -0
  133. package/dist/test/typescript/components/function-declaration.test.js +2 -1
  134. package/dist/test/typescript/components/function-declaration.test.js.map +1 -0
  135. package/dist/test/typescript/components/function-expression.test.js +9 -14
  136. package/dist/test/typescript/components/function-expression.test.js.map +1 -0
  137. package/dist/test/typescript/components/function-type.test.js +9 -14
  138. package/dist/test/typescript/components/function-type.test.js.map +1 -0
  139. package/dist/test/typescript/components/interface-declaration.test.js +2 -1
  140. package/dist/test/typescript/components/interface-declaration.test.js.map +1 -0
  141. package/dist/test/typescript/components/interface-method.test.js +19 -29
  142. package/dist/test/typescript/components/interface-method.test.js.map +1 -0
  143. package/dist/test/typescript/components/member-expression.test.js +2 -1
  144. package/dist/test/typescript/components/member-expression.test.js.map +1 -0
  145. package/dist/test/typescript/components/type-alias-declaration.test.js +2 -1
  146. package/dist/test/typescript/components/type-alias-declaration.test.js.map +1 -0
  147. package/dist/test/typescript/components/type-transform.test.js +2 -1
  148. package/dist/test/typescript/components/type-transform.test.js.map +1 -0
  149. package/dist/test/typescript/components/value-expression.test.js +2 -1
  150. package/dist/test/typescript/components/value-expression.test.js.map +1 -0
  151. package/dist/test/typescript/test-host.js +2 -1
  152. package/dist/test/typescript/test-host.js.map +1 -0
  153. package/dist/test/typescript/utils.js +2 -1
  154. package/dist/test/typescript/utils.js.map +1 -0
  155. package/dist/test/utils.d.ts.map +1 -1
  156. package/dist/test/utils.js +5 -2
  157. package/dist/test/utils.js.map +1 -0
  158. package/dist/test/vitest.setup.js +2 -1
  159. package/dist/test/vitest.setup.js.map +1 -0
  160. package/package.json +7 -7
  161. package/src/csharp/components/class/declaration.test.tsx +64 -102
  162. package/src/csharp/components/class/declaration.tsx +1 -1
  163. package/src/csharp/components/enum/declaration.test.tsx +47 -78
  164. package/src/csharp/components/property/property.test.tsx +44 -67
  165. package/src/csharp/components/type-expression.test.tsx +44 -93
  166. package/test/typescript/components/arrow-function.test.tsx +10 -28
  167. package/test/typescript/components/function-expression.test.tsx +10 -28
  168. package/test/typescript/components/function-type.test.tsx +10 -28
  169. package/test/typescript/components/interface-method.test.tsx +25 -68
  170. package/test/utils.ts +3 -1
@@ -1,11 +1,9 @@
1
- import { type Children, render } from "@alloy-js/core";
2
- import { d } from "@alloy-js/core/testing";
3
- import { Namespace, SourceFile } from "@alloy-js/csharp";
1
+ import { type Children } from "@alloy-js/core";
2
+ import { SourceFile } from "@alloy-js/csharp";
4
3
  import type { Model, ModelProperty } from "@typespec/compiler";
5
4
  import type { BasicTestRunner } from "@typespec/compiler/testing";
6
- import { beforeEach, describe, it } from "vitest";
5
+ import { beforeEach, describe, expect, it } from "vitest";
7
6
  import { createEmitterFrameworkTestRunner } from "../../../test/typescript/test-host.js";
8
- import { assertFileContents } from "../../../test/utils.js";
9
7
  import { Output } from "../../core/index.js";
10
8
  import { ClassDeclaration } from "./class/declaration.js";
11
9
  import { TypeExpression } from "./type-expression.jsx";
@@ -19,9 +17,7 @@ beforeEach(async () => {
19
17
  function Wrapper(props: { children: Children }) {
20
18
  return (
21
19
  <Output program={runner.program}>
22
- <Namespace name="TestNamespace">
23
- <SourceFile path="test.ts">{props.children}</SourceFile>
24
- </Namespace>
20
+ <SourceFile path="test.ts">{props.children}</SourceFile>
25
21
  </Output>
26
22
  );
27
23
  }
@@ -43,61 +39,37 @@ describe("map scalar to c# built-in types", () => {
43
39
  ["int64", "long"],
44
40
  ])("%s => %s", async (tspType, csType) => {
45
41
  const type = await compileType(tspType);
46
- const res = render(
42
+ expect(
47
43
  <Wrapper>
48
44
  <TypeExpression type={type} />
49
45
  </Wrapper>,
50
- );
51
-
52
- assertFileContents(
53
- res,
54
- d`
55
- namespace TestNamespace
56
- {
57
- ${csType}
58
- }
59
- `,
60
- );
46
+ ).toRenderTo(`
47
+ ${csType}
48
+ `);
61
49
  });
62
50
  });
63
51
 
64
52
  it("maps array to c# array", async () => {
65
53
  const type = await compileType("int32[]");
66
- const res = render(
54
+ expect(
67
55
  <Wrapper>
68
56
  <TypeExpression type={type} />
69
57
  </Wrapper>,
70
- );
71
-
72
- assertFileContents(
73
- res,
74
- d`
75
- namespace TestNamespace
76
- {
77
- int[]
78
- }
79
- `,
80
- );
58
+ ).toRenderTo(`
59
+ int[]
60
+ `);
81
61
  });
82
62
 
83
63
  describe("Record map to IDictionary", () => {
84
64
  it("for primitive types", async () => {
85
65
  const type = await compileType("Record<int32>");
86
- const res = render(
66
+ expect(
87
67
  <Wrapper>
88
68
  <TypeExpression type={type} />
89
69
  </Wrapper>,
90
- );
91
-
92
- assertFileContents(
93
- res,
94
- d`
95
- namespace TestNamespace
96
- {
97
- IDictionary<string, int>
98
- }
99
- `,
100
- );
70
+ ).toRenderTo(`
71
+ IDictionary<string, int>
72
+ `);
101
73
  });
102
74
 
103
75
  it("for models", async () => {
@@ -108,27 +80,19 @@ describe("Record map to IDictionary", () => {
108
80
  @test model Pet {}
109
81
  `)) as { test: ModelProperty; Pet: Model };
110
82
 
111
- const res = render(
83
+ expect(
112
84
  <Wrapper>
113
85
  <ClassDeclaration type={Pet} />
114
86
  <hbr />
115
87
  <TypeExpression type={test.type} />
116
88
  </Wrapper>,
117
- );
118
-
119
- assertFileContents(
120
- res,
121
- d`
122
- namespace TestNamespace
123
- {
124
- class Pet
125
- {
126
-
127
- }
128
- IDictionary<string, Pet>
129
- }
130
- `,
131
- );
89
+ ).toRenderTo(`
90
+ class Pet
91
+ {
92
+
93
+ }
94
+ IDictionary<string, Pet>
95
+ `);
132
96
  });
133
97
  });
134
98
 
@@ -140,24 +104,16 @@ describe("Nullable union", () => {
140
104
  }
141
105
  `)) as { Pet: Model };
142
106
 
143
- const res = render(
107
+ expect(
144
108
  <Wrapper>
145
109
  <ClassDeclaration type={Pet} />
146
110
  </Wrapper>,
147
- );
148
-
149
- assertFileContents(
150
- res,
151
- d`
152
- namespace TestNamespace
153
- {
154
- class Pet
155
- {
156
- public required bool? name { get; set; }
157
- }
158
- }
159
- `,
160
- );
111
+ ).toRenderTo(`
112
+ class Pet
113
+ {
114
+ public required bool? name { get; set; }
115
+ }
116
+ `);
161
117
  });
162
118
  });
163
119
 
@@ -172,26 +128,21 @@ describe("Literal types", () => {
172
128
  }
173
129
  `)) as { Pet: Model };
174
130
 
175
- const res = render(
131
+ expect(
176
132
  <Wrapper>
177
133
  <ClassDeclaration type={Pet} />
178
134
  </Wrapper>,
179
- );
180
-
181
- assertFileContents(
182
- res,
183
- d`
184
- namespace TestNamespace
185
- {
186
- class Pet
187
- {
188
- public required bool boolName { get; set; }
189
- public required int intName { get; set; }
190
- public required double doubleName { get; set; }
191
- public required string stringName { get; set; }
192
- }
193
- }
194
- `,
195
- );
135
+ ).toRenderTo(`
136
+ class Pet
137
+ {
138
+ public required bool boolName { get; set; }
139
+
140
+ public required int intName { get; set; }
141
+
142
+ public required double doubleName { get; set; }
143
+
144
+ public required string stringName { get; set; }
145
+ }
146
+ `);
196
147
  });
197
148
  });
@@ -1,12 +1,9 @@
1
- import { render } from "@alloy-js/core";
2
- import { d } from "@alloy-js/core/testing";
3
1
  import { SourceFile } from "@alloy-js/typescript";
4
2
  import type { Operation } from "@typespec/compiler";
5
3
  import type { BasicTestRunner } from "@typespec/compiler/testing";
6
- import { beforeEach, describe, it } from "vitest";
4
+ import { beforeEach, describe, expect, it } from "vitest";
7
5
  import { Output } from "../../../src/core/components/output.jsx";
8
6
  import { ArrowFunction } from "../../../src/typescript/components/arrow-function.jsx";
9
- import { assertFileContents } from "../../utils.js";
10
7
  import { createEmitterFrameworkTestRunner } from "../test-host.js";
11
8
 
12
9
  describe("arrow functions with a `type` prop", () => {
@@ -21,22 +18,17 @@ describe("arrow functions with a `type` prop", () => {
21
18
  @test op getName(id: string): string;
22
19
  `)) as { getName: Operation };
23
20
 
24
- const res = render(
21
+ expect(
25
22
  <Output program={runner.program}>
26
23
  <SourceFile path="test.ts">
27
24
  <ArrowFunction type={getName}>console.log("Hello!");</ArrowFunction>
28
25
  </SourceFile>
29
26
  </Output>,
30
- );
31
-
32
- assertFileContents(
33
- res,
34
- d`
27
+ ).toRenderTo(`
35
28
  (id: string): string => {
36
29
  console.log("Hello!");
37
30
  }
38
- `,
39
- );
31
+ `);
40
32
  });
41
33
 
42
34
  it("creates an async function", async () => {
@@ -44,20 +36,15 @@ describe("arrow functions with a `type` prop", () => {
44
36
  @test op getName(id: string): string;
45
37
  `)) as { getName: Operation };
46
38
 
47
- const res = render(
39
+ expect(
48
40
  <Output program={runner.program}>
49
41
  <SourceFile path="test.ts">
50
42
  <ArrowFunction async type={getName} />
51
43
  </SourceFile>
52
44
  </Output>,
53
- );
54
-
55
- assertFileContents(
56
- res,
57
- d`
45
+ ).toRenderTo(`
58
46
  async (id: string): Promise<string> => {}
59
- `,
60
- );
47
+ `);
61
48
  });
62
49
 
63
50
  it("can append extra parameters with raw params provided", async () => {
@@ -65,7 +52,7 @@ describe("arrow functions with a `type` prop", () => {
65
52
  @test op getName(id: string): string;
66
53
  `)) as { getName: Operation };
67
54
 
68
- const res = render(
55
+ expect(
69
56
  <Output program={runner.program}>
70
57
  <SourceFile path="test.ts">
71
58
  <ArrowFunction
@@ -74,13 +61,8 @@ describe("arrow functions with a `type` prop", () => {
74
61
  />
75
62
  </SourceFile>
76
63
  </Output>,
77
- );
78
-
79
- assertFileContents(
80
- res,
81
- d`
64
+ ).toRenderTo(`
82
65
  (additionalParam: number, id: string): string => {}
83
- `,
84
- );
66
+ `);
85
67
  });
86
68
  });
@@ -1,12 +1,9 @@
1
- import { render } from "@alloy-js/core";
2
- import { d } from "@alloy-js/core/testing";
3
1
  import { SourceFile } from "@alloy-js/typescript";
4
2
  import type { Operation } from "@typespec/compiler";
5
3
  import type { BasicTestRunner } from "@typespec/compiler/testing";
6
- import { beforeEach, describe, it } from "vitest";
4
+ import { beforeEach, describe, expect, it } from "vitest";
7
5
  import { Output } from "../../../src/core/components/output.jsx";
8
6
  import { FunctionExpression } from "../../../src/typescript/components/function-expression.jsx";
9
- import { assertFileContents } from "../../utils.js";
10
7
  import { createEmitterFrameworkTestRunner } from "../test-host.js";
11
8
 
12
9
  describe("function expressions with a `type` prop", () => {
@@ -21,22 +18,17 @@ describe("function expressions with a `type` prop", () => {
21
18
  @test op getName(id: string): string;
22
19
  `)) as { getName: Operation };
23
20
 
24
- const res = render(
21
+ expect(
25
22
  <Output program={runner.program}>
26
23
  <SourceFile path="test.ts">
27
24
  <FunctionExpression type={getName}>console.log("Hello!");</FunctionExpression>
28
25
  </SourceFile>
29
26
  </Output>,
30
- );
31
-
32
- assertFileContents(
33
- res,
34
- d`
27
+ ).toRenderTo(`
35
28
  function (id: string): string {
36
29
  console.log("Hello!");
37
30
  }
38
- `,
39
- );
31
+ `);
40
32
  });
41
33
 
42
34
  it("creates an async function", async () => {
@@ -44,20 +36,15 @@ describe("function expressions with a `type` prop", () => {
44
36
  @test op getName(id: string): string;
45
37
  `)) as { getName: Operation };
46
38
 
47
- const res = render(
39
+ expect(
48
40
  <Output program={runner.program}>
49
41
  <SourceFile path="test.ts">
50
42
  <FunctionExpression async type={getName} />
51
43
  </SourceFile>
52
44
  </Output>,
53
- );
54
-
55
- assertFileContents(
56
- res,
57
- d`
45
+ ).toRenderTo(`
58
46
  async function (id: string): Promise<string> {}
59
- `,
60
- );
47
+ `);
61
48
  });
62
49
 
63
50
  it("can append extra parameters with raw params provided", async () => {
@@ -65,7 +52,7 @@ describe("function expressions with a `type` prop", () => {
65
52
  @test op getName(id: string): string;
66
53
  `)) as { getName: Operation };
67
54
 
68
- const res = render(
55
+ expect(
69
56
  <Output program={runner.program}>
70
57
  <SourceFile path="test.ts">
71
58
  <FunctionExpression
@@ -74,13 +61,8 @@ describe("function expressions with a `type` prop", () => {
74
61
  />
75
62
  </SourceFile>
76
63
  </Output>,
77
- );
78
-
79
- assertFileContents(
80
- res,
81
- d`
64
+ ).toRenderTo(`
82
65
  function (additionalParam: number, id: string): string {}
83
- `,
84
- );
66
+ `);
85
67
  });
86
68
  });
@@ -1,12 +1,9 @@
1
- import { render } from "@alloy-js/core";
2
- import { d } from "@alloy-js/core/testing";
3
1
  import { SourceFile } from "@alloy-js/typescript";
4
2
  import type { Operation } from "@typespec/compiler";
5
3
  import type { BasicTestRunner } from "@typespec/compiler/testing";
6
- import { beforeEach, describe, it } from "vitest";
4
+ import { beforeEach, describe, expect, it } from "vitest";
7
5
  import { Output } from "../../../src/core/components/output.jsx";
8
6
  import { FunctionType } from "../../../src/typescript/index.js";
9
- import { assertFileContents } from "../../utils.js";
10
7
  import { createEmitterFrameworkTestRunner } from "../test-host.js";
11
8
 
12
9
  describe("function types with a `type` prop", () => {
@@ -21,20 +18,15 @@ describe("function types with a `type` prop", () => {
21
18
  @test op getName(id: string): string;
22
19
  `)) as { getName: Operation };
23
20
 
24
- const res = render(
21
+ expect(
25
22
  <Output program={runner.program}>
26
23
  <SourceFile path="test.ts">
27
24
  <FunctionType type={getName} />
28
25
  </SourceFile>
29
26
  </Output>,
30
- );
31
-
32
- assertFileContents(
33
- res,
34
- d`
27
+ ).toRenderTo(`
35
28
  (id: string) => string
36
- `,
37
- );
29
+ `);
38
30
  });
39
31
 
40
32
  it("creates an async function type", async () => {
@@ -42,20 +34,15 @@ describe("function types with a `type` prop", () => {
42
34
  @test op getName(id: string): string;
43
35
  `)) as { getName: Operation };
44
36
 
45
- const res = render(
37
+ expect(
46
38
  <Output program={runner.program}>
47
39
  <SourceFile path="test.ts">
48
40
  <FunctionType async type={getName} />
49
41
  </SourceFile>
50
42
  </Output>,
51
- );
52
-
53
- assertFileContents(
54
- res,
55
- d`
43
+ ).toRenderTo(`
56
44
  (id: string) => Promise<string>
57
- `,
58
- );
45
+ `);
59
46
  });
60
47
 
61
48
  it("can append extra parameters with raw params provided", async () => {
@@ -63,19 +50,14 @@ describe("function types with a `type` prop", () => {
63
50
  @test op getName(id: string): string;
64
51
  `)) as { getName: Operation };
65
52
 
66
- const res = render(
53
+ expect(
67
54
  <Output program={runner.program}>
68
55
  <SourceFile path="test.ts">
69
56
  <FunctionType type={getName} parameters={[{ name: "additionalParam", type: "number" }]} />
70
57
  </SourceFile>
71
58
  </Output>,
72
- );
73
-
74
- assertFileContents(
75
- res,
76
- d`
59
+ ).toRenderTo(`
77
60
  (additionalParam: number, id: string) => string
78
- `,
79
- );
61
+ `);
80
62
  });
81
63
  });
@@ -1,12 +1,9 @@
1
- import { render } from "@alloy-js/core";
2
- import { d } from "@alloy-js/core/testing";
3
1
  import { InterfaceDeclaration, SourceFile } from "@alloy-js/typescript";
4
2
  import type { Operation } from "@typespec/compiler";
5
3
  import type { BasicTestRunner } from "@typespec/compiler/testing";
6
- import { beforeEach, describe, it } from "vitest";
4
+ import { beforeEach, describe, expect, it } from "vitest";
7
5
  import { Output } from "../../../src/core/components/output.jsx";
8
6
  import { InterfaceMethod } from "../../../src/typescript/components/interface-method.jsx";
9
- import { assertFileContents } from "../../utils.js";
10
7
  import { createEmitterFrameworkTestRunner, getProgram } from "../test-host.js";
11
8
 
12
9
  describe("interface methods with a `type` prop", () => {
@@ -21,7 +18,7 @@ describe("interface methods with a `type` prop", () => {
21
18
  @test op getName(id: string): string;
22
19
  `)) as { getName: Operation };
23
20
 
24
- const res = render(
21
+ expect(
25
22
  <Output program={runner.program}>
26
23
  <SourceFile path="test.ts">
27
24
  <InterfaceDeclaration name="basicInterface">
@@ -29,16 +26,11 @@ describe("interface methods with a `type` prop", () => {
29
26
  </InterfaceDeclaration>
30
27
  </SourceFile>
31
28
  </Output>,
32
- );
33
-
34
- assertFileContents(
35
- res,
36
- d`
29
+ ).toRenderTo(`
37
30
  interface basicInterface {
38
31
  getName(id: string): string
39
32
  }
40
- `,
41
- );
33
+ `);
42
34
  });
43
35
 
44
36
  it("creates an async interface function", async () => {
@@ -46,7 +38,7 @@ describe("interface methods with a `type` prop", () => {
46
38
  @test op getName(id: string): string;
47
39
  `)) as { getName: Operation };
48
40
 
49
- const res = render(
41
+ expect(
50
42
  <Output program={runner.program}>
51
43
  <SourceFile path="test.ts">
52
44
  <InterfaceDeclaration name="basicInterface">
@@ -54,16 +46,11 @@ describe("interface methods with a `type` prop", () => {
54
46
  </InterfaceDeclaration>
55
47
  </SourceFile>
56
48
  </Output>,
57
- );
58
-
59
- assertFileContents(
60
- res,
61
- d`
49
+ ).toRenderTo(`
62
50
  interface basicInterface {
63
51
  getName(id: string): Promise<string>
64
52
  }
65
- `,
66
- );
53
+ `);
67
54
  });
68
55
 
69
56
  it("can append extra parameters with raw params provided", async () => {
@@ -71,7 +58,7 @@ describe("interface methods with a `type` prop", () => {
71
58
  @test op getName(id: string): string;
72
59
  `)) as { getName: Operation };
73
60
 
74
- const res = render(
61
+ expect(
75
62
  <Output program={runner.program}>
76
63
  <SourceFile path="test.ts">
77
64
  <InterfaceDeclaration name="basicInterface">
@@ -83,16 +70,11 @@ describe("interface methods with a `type` prop", () => {
83
70
  </InterfaceDeclaration>
84
71
  </SourceFile>
85
72
  </Output>,
86
- );
87
-
88
- assertFileContents(
89
- res,
90
- d`
73
+ ).toRenderTo(`
91
74
  interface basicInterface {
92
75
  getName(id: string, foo: string): string
93
76
  }
94
- `,
95
- );
77
+ `);
96
78
  });
97
79
 
98
80
  it("can prepend extra parameters with raw params provided", async () => {
@@ -100,7 +82,7 @@ describe("interface methods with a `type` prop", () => {
100
82
  @test op getName(id: string): string;
101
83
  `)) as { getName: Operation };
102
84
 
103
- const res = render(
85
+ expect(
104
86
  <Output program={runner.program}>
105
87
  <SourceFile path="test.ts">
106
88
  <InterfaceDeclaration name="basicInterface">
@@ -112,16 +94,11 @@ describe("interface methods with a `type` prop", () => {
112
94
  </InterfaceDeclaration>
113
95
  </SourceFile>
114
96
  </Output>,
115
- );
116
-
117
- assertFileContents(
118
- res,
119
- d`
97
+ ).toRenderTo(`
120
98
  interface basicInterface {
121
99
  getName(foo: string, id: string): string
122
100
  }
123
- `,
124
- );
101
+ `);
125
102
  });
126
103
 
127
104
  it("can replace parameters with raw params provided", async () => {
@@ -129,7 +106,7 @@ describe("interface methods with a `type` prop", () => {
129
106
  @test op getName(id: string): string;
130
107
  `)) as { getName: Operation };
131
108
 
132
- const res = render(
109
+ expect(
133
110
  <Output program={runner.program}>
134
111
  <SourceFile path="test.ts">
135
112
  <InterfaceDeclaration name="basicInterface">
@@ -144,16 +121,11 @@ describe("interface methods with a `type` prop", () => {
144
121
  </InterfaceDeclaration>
145
122
  </SourceFile>
146
123
  </Output>,
147
- );
148
-
149
- assertFileContents(
150
- res,
151
- d`
124
+ ).toRenderTo(`
152
125
  interface basicInterface {
153
126
  getName(foo: string, bar: number): string
154
127
  }
155
- `,
156
- );
128
+ `);
157
129
  });
158
130
 
159
131
  it("can override return type", async () => {
@@ -161,7 +133,7 @@ describe("interface methods with a `type` prop", () => {
161
133
  @test op getName(id: string): string;
162
134
  `)) as { getName: Operation };
163
135
 
164
- const res = render(
136
+ expect(
165
137
  <Output program={runner.program}>
166
138
  <SourceFile path="test.ts">
167
139
  <InterfaceDeclaration name="basicInterface">
@@ -169,16 +141,11 @@ describe("interface methods with a `type` prop", () => {
169
141
  </InterfaceDeclaration>
170
142
  </SourceFile>
171
143
  </Output>,
172
- );
173
-
174
- assertFileContents(
175
- res,
176
- d`
144
+ ).toRenderTo(`
177
145
  interface basicInterface {
178
146
  getName(id: string): Promise<Record<string, unknown>>
179
147
  }
180
- `,
181
- );
148
+ `);
182
149
  });
183
150
 
184
151
  it("can override method name", async () => {
@@ -186,7 +153,7 @@ describe("interface methods with a `type` prop", () => {
186
153
  @test op getName(id: string): string;
187
154
  `)) as { getName: Operation };
188
155
 
189
- const res = render(
156
+ expect(
190
157
  <Output program={runner.program}>
191
158
  <SourceFile path="test.ts">
192
159
  <InterfaceDeclaration name="basicInterface">
@@ -194,23 +161,18 @@ describe("interface methods with a `type` prop", () => {
194
161
  </InterfaceDeclaration>
195
162
  </SourceFile>
196
163
  </Output>,
197
- );
198
-
199
- assertFileContents(
200
- res,
201
- d`
164
+ ).toRenderTo(`
202
165
  interface basicInterface {
203
166
  getNameCustom(id: string): string
204
167
  }
205
- `,
206
- );
168
+ `);
207
169
  });
208
170
  });
209
171
 
210
172
  describe("interface methods without a `type` prop", () => {
211
173
  it("renders a plain interface method", async () => {
212
174
  const program = await getProgram("");
213
- const res = render(
175
+ expect(
214
176
  <Output program={program}>
215
177
  <SourceFile path="test.ts">
216
178
  <InterfaceDeclaration name="basicInterface">
@@ -222,15 +184,10 @@ describe("interface methods without a `type` prop", () => {
222
184
  </InterfaceDeclaration>
223
185
  </SourceFile>
224
186
  </Output>,
225
- );
226
-
227
- assertFileContents(
228
- res,
229
- d`
187
+ ).toRenderTo(`
230
188
  interface basicInterface {
231
189
  plainMethod(param1: string): number
232
190
  }
233
- `,
234
- );
191
+ `);
235
192
  });
236
193
  });