@goast/kotlin 0.4.10 → 0.4.12-beta1

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 (532) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +45 -45
  3. package/assets/client/okhttp3/ApiClient.kt +252 -252
  4. package/esm/src/ast/references/jakarta.d.ts +4 -0
  5. package/esm/src/ast/references/jakarta.d.ts.map +1 -1
  6. package/esm/src/ast/references/jakarta.js +4 -0
  7. package/esm/src/ast/references/spring.d.ts +1 -0
  8. package/esm/src/ast/references/spring.d.ts.map +1 -1
  9. package/esm/src/ast/references/spring.js +1 -0
  10. package/esm/src/generators/models/args.d.ts +1 -5
  11. package/esm/src/generators/models/args.d.ts.map +1 -1
  12. package/esm/src/generators/models/model-generator.d.ts +1 -2
  13. package/esm/src/generators/models/model-generator.d.ts.map +1 -1
  14. package/esm/src/generators/models/model-generator.js +46 -15
  15. package/esm/src/generators/services/okhttp3-clients/okhttp3-client-generator.d.ts.map +1 -1
  16. package/esm/src/generators/services/okhttp3-clients/okhttp3-client-generator.js +36 -28
  17. package/esm/src/generators/services/spring-controllers/spring-controller-generator.d.ts.map +1 -1
  18. package/esm/src/generators/services/spring-controllers/spring-controller-generator.js +10 -6
  19. package/package.json +2 -2
  20. package/script/src/ast/references/jakarta.d.ts +4 -0
  21. package/script/src/ast/references/jakarta.d.ts.map +1 -1
  22. package/script/src/ast/references/jakarta.js +5 -1
  23. package/script/src/ast/references/spring.d.ts +1 -0
  24. package/script/src/ast/references/spring.d.ts.map +1 -1
  25. package/script/src/ast/references/spring.js +2 -1
  26. package/script/src/generators/models/args.d.ts +1 -5
  27. package/script/src/generators/models/args.d.ts.map +1 -1
  28. package/script/src/generators/models/model-generator.d.ts +1 -2
  29. package/script/src/generators/models/model-generator.d.ts.map +1 -1
  30. package/script/src/generators/models/model-generator.js +46 -15
  31. package/script/src/generators/services/okhttp3-clients/okhttp3-client-generator.d.ts.map +1 -1
  32. package/script/src/generators/services/okhttp3-clients/okhttp3-client-generator.js +36 -28
  33. package/script/src/generators/services/spring-controllers/spring-controller-generator.d.ts.map +1 -1
  34. package/script/src/generators/services/spring-controllers/spring-controller-generator.js +10 -6
  35. package/esm/_dnt.test_polyfills.d.ts +0 -29
  36. package/esm/_dnt.test_polyfills.d.ts.map +0 -1
  37. package/esm/_dnt.test_polyfills.js +0 -31
  38. package/esm/_dnt.test_shims.d.ts +0 -6
  39. package/esm/_dnt.test_shims.d.ts.map +0 -1
  40. package/esm/_dnt.test_shims.js +0 -61
  41. package/esm/deps/jsr.io/@std/assert/1.0.11/assertion_error.d.ts +0 -26
  42. package/esm/deps/jsr.io/@std/assert/1.0.11/assertion_error.d.ts.map +0 -1
  43. package/esm/deps/jsr.io/@std/assert/1.0.11/assertion_error.js +0 -30
  44. package/esm/deps/jsr.io/@std/assert/1.0.11/equal.d.ts +0 -17
  45. package/esm/deps/jsr.io/@std/assert/1.0.11/equal.d.ts.map +0 -1
  46. package/esm/deps/jsr.io/@std/assert/1.0.11/equal.js +0 -183
  47. package/esm/deps/jsr.io/@std/assert/1.0.11/equals.d.ts +0 -35
  48. package/esm/deps/jsr.io/@std/assert/1.0.11/equals.d.ts.map +0 -1
  49. package/esm/deps/jsr.io/@std/assert/1.0.11/equals.js +0 -58
  50. package/esm/deps/jsr.io/@std/assert/1.0.11/false.d.ts +0 -18
  51. package/esm/deps/jsr.io/@std/assert/1.0.11/false.d.ts.map +0 -1
  52. package/esm/deps/jsr.io/@std/assert/1.0.11/false.js +0 -22
  53. package/esm/deps/jsr.io/@std/assert/1.0.11/instance_of.d.ts +0 -23
  54. package/esm/deps/jsr.io/@std/assert/1.0.11/instance_of.d.ts.map +0 -1
  55. package/esm/deps/jsr.io/@std/assert/1.0.11/instance_of.js +0 -53
  56. package/esm/deps/jsr.io/@std/assert/1.0.11/is_error.d.ts +0 -25
  57. package/esm/deps/jsr.io/@std/assert/1.0.11/is_error.d.ts.map +0 -1
  58. package/esm/deps/jsr.io/@std/assert/1.0.11/is_error.js +0 -54
  59. package/esm/deps/jsr.io/@std/assert/1.0.11/match.d.ts +0 -18
  60. package/esm/deps/jsr.io/@std/assert/1.0.11/match.d.ts.map +0 -1
  61. package/esm/deps/jsr.io/@std/assert/1.0.11/match.js +0 -26
  62. package/esm/deps/jsr.io/@std/assert/1.0.11/not_instance_of.d.ts +0 -20
  63. package/esm/deps/jsr.io/@std/assert/1.0.11/not_instance_of.d.ts.map +0 -1
  64. package/esm/deps/jsr.io/@std/assert/1.0.11/not_instance_of.js +0 -29
  65. package/esm/deps/jsr.io/@std/assert/1.0.11/not_match.d.ts +0 -18
  66. package/esm/deps/jsr.io/@std/assert/1.0.11/not_match.d.ts.map +0 -1
  67. package/esm/deps/jsr.io/@std/assert/1.0.11/not_match.js +0 -26
  68. package/esm/deps/jsr.io/@std/assert/1.0.11/not_strict_equals.d.ts +0 -23
  69. package/esm/deps/jsr.io/@std/assert/1.0.11/not_strict_equals.d.ts.map +0 -1
  70. package/esm/deps/jsr.io/@std/assert/1.0.11/not_strict_equals.js +0 -32
  71. package/esm/deps/jsr.io/@std/assert/1.0.11/rejects.d.ts +0 -42
  72. package/esm/deps/jsr.io/@std/assert/1.0.11/rejects.d.ts.map +0 -1
  73. package/esm/deps/jsr.io/@std/assert/1.0.11/rejects.js +0 -53
  74. package/esm/deps/jsr.io/@std/assert/1.0.11/strict_equals.d.ts +0 -24
  75. package/esm/deps/jsr.io/@std/assert/1.0.11/strict_equals.d.ts.map +0 -1
  76. package/esm/deps/jsr.io/@std/assert/1.0.11/strict_equals.js +0 -57
  77. package/esm/deps/jsr.io/@std/expect/1.0.13/_assert_equals.d.ts +0 -20
  78. package/esm/deps/jsr.io/@std/expect/1.0.13/_assert_equals.d.ts.map +0 -1
  79. package/esm/deps/jsr.io/@std/expect/1.0.13/_assert_equals.js +0 -29
  80. package/esm/deps/jsr.io/@std/expect/1.0.13/_assert_is_error.d.ts +0 -14
  81. package/esm/deps/jsr.io/@std/expect/1.0.13/_assert_is_error.d.ts.map +0 -1
  82. package/esm/deps/jsr.io/@std/expect/1.0.13/_assert_is_error.js +0 -43
  83. package/esm/deps/jsr.io/@std/expect/1.0.13/_assert_not_equals.d.ts +0 -17
  84. package/esm/deps/jsr.io/@std/expect/1.0.13/_assert_not_equals.d.ts.map +0 -1
  85. package/esm/deps/jsr.io/@std/expect/1.0.13/_assert_not_equals.js +0 -26
  86. package/esm/deps/jsr.io/@std/expect/1.0.13/_assertions.d.ts +0 -4
  87. package/esm/deps/jsr.io/@std/expect/1.0.13/_assertions.d.ts.map +0 -1
  88. package/esm/deps/jsr.io/@std/expect/1.0.13/_assertions.js +0 -13
  89. package/esm/deps/jsr.io/@std/expect/1.0.13/_asymmetric_matchers.d.ts +0 -46
  90. package/esm/deps/jsr.io/@std/expect/1.0.13/_asymmetric_matchers.d.ts.map +0 -1
  91. package/esm/deps/jsr.io/@std/expect/1.0.13/_asymmetric_matchers.js +0 -161
  92. package/esm/deps/jsr.io/@std/expect/1.0.13/_build_message.d.ts +0 -6
  93. package/esm/deps/jsr.io/@std/expect/1.0.13/_build_message.d.ts.map +0 -1
  94. package/esm/deps/jsr.io/@std/expect/1.0.13/_build_message.js +0 -29
  95. package/esm/deps/jsr.io/@std/expect/1.0.13/_custom_equality_tester.d.ts +0 -4
  96. package/esm/deps/jsr.io/@std/expect/1.0.13/_custom_equality_tester.d.ts.map +0 -1
  97. package/esm/deps/jsr.io/@std/expect/1.0.13/_custom_equality_tester.js +0 -11
  98. package/esm/deps/jsr.io/@std/expect/1.0.13/_equal.d.ts +0 -9
  99. package/esm/deps/jsr.io/@std/expect/1.0.13/_equal.d.ts.map +0 -1
  100. package/esm/deps/jsr.io/@std/expect/1.0.13/_equal.js +0 -191
  101. package/esm/deps/jsr.io/@std/expect/1.0.13/_extend.d.ts +0 -4
  102. package/esm/deps/jsr.io/@std/expect/1.0.13/_extend.d.ts.map +0 -1
  103. package/esm/deps/jsr.io/@std/expect/1.0.13/_extend.js +0 -11
  104. package/esm/deps/jsr.io/@std/expect/1.0.13/_inspect_args.d.ts +0 -3
  105. package/esm/deps/jsr.io/@std/expect/1.0.13/_inspect_args.d.ts.map +0 -1
  106. package/esm/deps/jsr.io/@std/expect/1.0.13/_inspect_args.js +0 -12
  107. package/esm/deps/jsr.io/@std/expect/1.0.13/_matchers.d.ts +0 -34
  108. package/esm/deps/jsr.io/@std/expect/1.0.13/_matchers.d.ts.map +0 -1
  109. package/esm/deps/jsr.io/@std/expect/1.0.13/_matchers.js +0 -714
  110. package/esm/deps/jsr.io/@std/expect/1.0.13/_mock_util.d.ts +0 -11
  111. package/esm/deps/jsr.io/@std/expect/1.0.13/_mock_util.d.ts.map +0 -1
  112. package/esm/deps/jsr.io/@std/expect/1.0.13/_mock_util.js +0 -10
  113. package/esm/deps/jsr.io/@std/expect/1.0.13/_serializer.d.ts +0 -4
  114. package/esm/deps/jsr.io/@std/expect/1.0.13/_serializer.d.ts.map +0 -1
  115. package/esm/deps/jsr.io/@std/expect/1.0.13/_serializer.js +0 -10
  116. package/esm/deps/jsr.io/@std/expect/1.0.13/_types.d.ts +0 -843
  117. package/esm/deps/jsr.io/@std/expect/1.0.13/_types.d.ts.map +0 -1
  118. package/esm/deps/jsr.io/@std/expect/1.0.13/_types.js +0 -3
  119. package/esm/deps/jsr.io/@std/expect/1.0.13/_utils.d.ts +0 -9
  120. package/esm/deps/jsr.io/@std/expect/1.0.13/_utils.d.ts.map +0 -1
  121. package/esm/deps/jsr.io/@std/expect/1.0.13/_utils.js +0 -218
  122. package/esm/deps/jsr.io/@std/expect/1.0.13/expect.d.ts +0 -60
  123. package/esm/deps/jsr.io/@std/expect/1.0.13/expect.d.ts.map +0 -1
  124. package/esm/deps/jsr.io/@std/expect/1.0.13/expect.js +0 -523
  125. package/esm/deps/jsr.io/@std/internal/1.0.5/assertion_state.d.ts +0 -160
  126. package/esm/deps/jsr.io/@std/internal/1.0.5/assertion_state.d.ts.map +0 -1
  127. package/esm/deps/jsr.io/@std/internal/1.0.5/assertion_state.js +0 -199
  128. package/esm/deps/jsr.io/@std/internal/1.0.5/build_message.d.ts +0 -82
  129. package/esm/deps/jsr.io/@std/internal/1.0.5/build_message.d.ts.map +0 -1
  130. package/esm/deps/jsr.io/@std/internal/1.0.5/build_message.js +0 -111
  131. package/esm/deps/jsr.io/@std/internal/1.0.5/diff.d.ts +0 -140
  132. package/esm/deps/jsr.io/@std/internal/1.0.5/diff.d.ts.map +0 -1
  133. package/esm/deps/jsr.io/@std/internal/1.0.5/diff.js +0 -277
  134. package/esm/deps/jsr.io/@std/internal/1.0.5/diff_str.d.ts +0 -99
  135. package/esm/deps/jsr.io/@std/internal/1.0.5/diff_str.d.ts.map +0 -1
  136. package/esm/deps/jsr.io/@std/internal/1.0.5/diff_str.js +0 -180
  137. package/esm/deps/jsr.io/@std/internal/1.0.5/format.d.ts +0 -2
  138. package/esm/deps/jsr.io/@std/internal/1.0.5/format.d.ts.map +0 -1
  139. package/esm/deps/jsr.io/@std/internal/1.0.5/format.js +0 -37
  140. package/esm/deps/jsr.io/@std/internal/1.0.5/styles.d.ts +0 -159
  141. package/esm/deps/jsr.io/@std/internal/1.0.5/styles.d.ts.map +0 -1
  142. package/esm/deps/jsr.io/@std/internal/1.0.5/styles.js +0 -207
  143. package/esm/deps/jsr.io/@std/internal/1.0.5/types.d.ts +0 -16
  144. package/esm/deps/jsr.io/@std/internal/1.0.5/types.d.ts.map +0 -1
  145. package/esm/deps/jsr.io/@std/internal/1.0.5/types.js +0 -2
  146. package/esm/deps/jsr.io/@std/testing/1.0.9/_mock_utils.d.ts +0 -15
  147. package/esm/deps/jsr.io/@std/testing/1.0.9/_mock_utils.d.ts.map +0 -1
  148. package/esm/deps/jsr.io/@std/testing/1.0.9/_mock_utils.js +0 -35
  149. package/esm/deps/jsr.io/@std/testing/1.0.9/_test_suite.d.ts +0 -79
  150. package/esm/deps/jsr.io/@std/testing/1.0.9/_test_suite.d.ts.map +0 -1
  151. package/esm/deps/jsr.io/@std/testing/1.0.9/_test_suite.js +0 -380
  152. package/esm/deps/jsr.io/@std/testing/1.0.9/bdd.d.ts +0 -738
  153. package/esm/deps/jsr.io/@std/testing/1.0.9/bdd.d.ts.map +0 -1
  154. package/esm/deps/jsr.io/@std/testing/1.0.9/bdd.js +0 -654
  155. package/esm/deps/jsr.io/@std/testing/1.0.9/mock.d.ts +0 -674
  156. package/esm/deps/jsr.io/@std/testing/1.0.9/mock.d.ts.map +0 -1
  157. package/esm/deps/jsr.io/@std/testing/1.0.9/mock.js +0 -1083
  158. package/esm/src/ast/nodes/annotation.test.d.ts +0 -2
  159. package/esm/src/ast/nodes/annotation.test.d.ts.map +0 -1
  160. package/esm/src/ast/nodes/annotation.test.js +0 -56
  161. package/esm/src/ast/nodes/argument.test.d.ts +0 -2
  162. package/esm/src/ast/nodes/argument.test.d.ts.map +0 -1
  163. package/esm/src/ast/nodes/argument.test.js +0 -33
  164. package/esm/src/ast/nodes/call.test.d.ts +0 -2
  165. package/esm/src/ast/nodes/call.test.d.ts.map +0 -1
  166. package/esm/src/ast/nodes/call.test.js +0 -35
  167. package/esm/src/ast/nodes/class.test.d.ts +0 -2
  168. package/esm/src/ast/nodes/class.test.d.ts.map +0 -1
  169. package/esm/src/ast/nodes/class.test.js +0 -219
  170. package/esm/src/ast/nodes/constructor.test.d.ts +0 -2
  171. package/esm/src/ast/nodes/constructor.test.d.ts.map +0 -1
  172. package/esm/src/ast/nodes/constructor.test.js +0 -139
  173. package/esm/src/ast/nodes/doc-tag.test.d.ts +0 -2
  174. package/esm/src/ast/nodes/doc-tag.test.d.ts.map +0 -1
  175. package/esm/src/ast/nodes/doc-tag.test.js +0 -67
  176. package/esm/src/ast/nodes/doc.test.d.ts +0 -2
  177. package/esm/src/ast/nodes/doc.test.d.ts.map +0 -1
  178. package/esm/src/ast/nodes/doc.test.js +0 -33
  179. package/esm/src/ast/nodes/enum-value.test.d.ts +0 -2
  180. package/esm/src/ast/nodes/enum-value.test.d.ts.map +0 -1
  181. package/esm/src/ast/nodes/enum-value.test.js +0 -115
  182. package/esm/src/ast/nodes/enum.test.d.ts +0 -2
  183. package/esm/src/ast/nodes/enum.test.d.ts.map +0 -1
  184. package/esm/src/ast/nodes/enum.test.js +0 -129
  185. package/esm/src/ast/nodes/function.test.d.ts +0 -2
  186. package/esm/src/ast/nodes/function.test.d.ts.map +0 -1
  187. package/esm/src/ast/nodes/function.test.js +0 -160
  188. package/esm/src/ast/nodes/generic-parameter.test.d.ts +0 -2
  189. package/esm/src/ast/nodes/generic-parameter.test.d.ts.map +0 -1
  190. package/esm/src/ast/nodes/generic-parameter.test.js +0 -49
  191. package/esm/src/ast/nodes/init-block.test.d.ts +0 -2
  192. package/esm/src/ast/nodes/init-block.test.d.ts.map +0 -1
  193. package/esm/src/ast/nodes/init-block.test.js +0 -28
  194. package/esm/src/ast/nodes/interface.test.d.ts +0 -2
  195. package/esm/src/ast/nodes/interface.test.d.ts.map +0 -1
  196. package/esm/src/ast/nodes/interface.test.js +0 -121
  197. package/esm/src/ast/nodes/object.test.d.ts +0 -2
  198. package/esm/src/ast/nodes/object.test.d.ts.map +0 -1
  199. package/esm/src/ast/nodes/object.test.js +0 -78
  200. package/esm/src/ast/nodes/parameter.test.d.ts +0 -2
  201. package/esm/src/ast/nodes/parameter.test.d.ts.map +0 -1
  202. package/esm/src/ast/nodes/parameter.test.js +0 -152
  203. package/esm/src/ast/nodes/property.test.d.ts +0 -2
  204. package/esm/src/ast/nodes/property.test.d.ts.map +0 -1
  205. package/esm/src/ast/nodes/property.test.js +0 -206
  206. package/esm/src/ast/nodes/reference.test.d.ts +0 -2
  207. package/esm/src/ast/nodes/reference.test.d.ts.map +0 -1
  208. package/esm/src/ast/nodes/reference.test.js +0 -36
  209. package/esm/src/ast/nodes/string.test.d.ts +0 -2
  210. package/esm/src/ast/nodes/string.test.d.ts.map +0 -1
  211. package/esm/src/ast/nodes/string.test.js +0 -48
  212. package/esm/src/import-collection.test.d.ts +0 -2
  213. package/esm/src/import-collection.test.d.ts.map +0 -1
  214. package/esm/src/import-collection.test.js +0 -99
  215. package/esm/tests/openapi-models.test.d.ts +0 -2
  216. package/esm/tests/openapi-models.test.d.ts.map +0 -1
  217. package/esm/tests/openapi-models.test.js +0 -45
  218. package/script/_dnt.test_polyfills.d.ts +0 -29
  219. package/script/_dnt.test_polyfills.d.ts.map +0 -1
  220. package/script/_dnt.test_polyfills.js +0 -32
  221. package/script/_dnt.test_shims.d.ts +0 -6
  222. package/script/_dnt.test_shims.d.ts.map +0 -1
  223. package/script/_dnt.test_shims.js +0 -65
  224. package/script/deps/jsr.io/@std/assert/1.0.11/assertion_error.d.ts +0 -26
  225. package/script/deps/jsr.io/@std/assert/1.0.11/assertion_error.d.ts.map +0 -1
  226. package/script/deps/jsr.io/@std/assert/1.0.11/assertion_error.js +0 -34
  227. package/script/deps/jsr.io/@std/assert/1.0.11/equal.d.ts +0 -17
  228. package/script/deps/jsr.io/@std/assert/1.0.11/equal.d.ts.map +0 -1
  229. package/script/deps/jsr.io/@std/assert/1.0.11/equal.js +0 -187
  230. package/script/deps/jsr.io/@std/assert/1.0.11/equals.d.ts +0 -35
  231. package/script/deps/jsr.io/@std/assert/1.0.11/equals.d.ts.map +0 -1
  232. package/script/deps/jsr.io/@std/assert/1.0.11/equals.js +0 -61
  233. package/script/deps/jsr.io/@std/assert/1.0.11/false.d.ts +0 -18
  234. package/script/deps/jsr.io/@std/assert/1.0.11/false.d.ts.map +0 -1
  235. package/script/deps/jsr.io/@std/assert/1.0.11/false.js +0 -25
  236. package/script/deps/jsr.io/@std/assert/1.0.11/instance_of.d.ts +0 -23
  237. package/script/deps/jsr.io/@std/assert/1.0.11/instance_of.d.ts.map +0 -1
  238. package/script/deps/jsr.io/@std/assert/1.0.11/instance_of.js +0 -56
  239. package/script/deps/jsr.io/@std/assert/1.0.11/is_error.d.ts +0 -25
  240. package/script/deps/jsr.io/@std/assert/1.0.11/is_error.d.ts.map +0 -1
  241. package/script/deps/jsr.io/@std/assert/1.0.11/is_error.js +0 -57
  242. package/script/deps/jsr.io/@std/assert/1.0.11/match.d.ts +0 -18
  243. package/script/deps/jsr.io/@std/assert/1.0.11/match.d.ts.map +0 -1
  244. package/script/deps/jsr.io/@std/assert/1.0.11/match.js +0 -29
  245. package/script/deps/jsr.io/@std/assert/1.0.11/not_instance_of.d.ts +0 -20
  246. package/script/deps/jsr.io/@std/assert/1.0.11/not_instance_of.d.ts.map +0 -1
  247. package/script/deps/jsr.io/@std/assert/1.0.11/not_instance_of.js +0 -32
  248. package/script/deps/jsr.io/@std/assert/1.0.11/not_match.d.ts +0 -18
  249. package/script/deps/jsr.io/@std/assert/1.0.11/not_match.d.ts.map +0 -1
  250. package/script/deps/jsr.io/@std/assert/1.0.11/not_match.js +0 -29
  251. package/script/deps/jsr.io/@std/assert/1.0.11/not_strict_equals.d.ts +0 -23
  252. package/script/deps/jsr.io/@std/assert/1.0.11/not_strict_equals.d.ts.map +0 -1
  253. package/script/deps/jsr.io/@std/assert/1.0.11/not_strict_equals.js +0 -35
  254. package/script/deps/jsr.io/@std/assert/1.0.11/rejects.d.ts +0 -42
  255. package/script/deps/jsr.io/@std/assert/1.0.11/rejects.d.ts.map +0 -1
  256. package/script/deps/jsr.io/@std/assert/1.0.11/rejects.js +0 -56
  257. package/script/deps/jsr.io/@std/assert/1.0.11/strict_equals.d.ts +0 -24
  258. package/script/deps/jsr.io/@std/assert/1.0.11/strict_equals.d.ts.map +0 -1
  259. package/script/deps/jsr.io/@std/assert/1.0.11/strict_equals.js +0 -60
  260. package/script/deps/jsr.io/@std/expect/1.0.13/_assert_equals.d.ts +0 -20
  261. package/script/deps/jsr.io/@std/expect/1.0.13/_assert_equals.d.ts.map +0 -1
  262. package/script/deps/jsr.io/@std/expect/1.0.13/_assert_equals.js +0 -32
  263. package/script/deps/jsr.io/@std/expect/1.0.13/_assert_is_error.d.ts +0 -14
  264. package/script/deps/jsr.io/@std/expect/1.0.13/_assert_is_error.d.ts.map +0 -1
  265. package/script/deps/jsr.io/@std/expect/1.0.13/_assert_is_error.js +0 -46
  266. package/script/deps/jsr.io/@std/expect/1.0.13/_assert_not_equals.d.ts +0 -17
  267. package/script/deps/jsr.io/@std/expect/1.0.13/_assert_not_equals.d.ts.map +0 -1
  268. package/script/deps/jsr.io/@std/expect/1.0.13/_assert_not_equals.js +0 -29
  269. package/script/deps/jsr.io/@std/expect/1.0.13/_assertions.d.ts +0 -4
  270. package/script/deps/jsr.io/@std/expect/1.0.13/_assertions.d.ts.map +0 -1
  271. package/script/deps/jsr.io/@std/expect/1.0.13/_assertions.js +0 -18
  272. package/script/deps/jsr.io/@std/expect/1.0.13/_asymmetric_matchers.d.ts +0 -46
  273. package/script/deps/jsr.io/@std/expect/1.0.13/_asymmetric_matchers.d.ts.map +0 -1
  274. package/script/deps/jsr.io/@std/expect/1.0.13/_asymmetric_matchers.js +0 -183
  275. package/script/deps/jsr.io/@std/expect/1.0.13/_build_message.d.ts +0 -6
  276. package/script/deps/jsr.io/@std/expect/1.0.13/_build_message.d.ts.map +0 -1
  277. package/script/deps/jsr.io/@std/expect/1.0.13/_build_message.js +0 -33
  278. package/script/deps/jsr.io/@std/expect/1.0.13/_custom_equality_tester.d.ts +0 -4
  279. package/script/deps/jsr.io/@std/expect/1.0.13/_custom_equality_tester.d.ts.map +0 -1
  280. package/script/deps/jsr.io/@std/expect/1.0.13/_custom_equality_tester.js +0 -15
  281. package/script/deps/jsr.io/@std/expect/1.0.13/_equal.d.ts +0 -9
  282. package/script/deps/jsr.io/@std/expect/1.0.13/_equal.d.ts.map +0 -1
  283. package/script/deps/jsr.io/@std/expect/1.0.13/_equal.js +0 -194
  284. package/script/deps/jsr.io/@std/expect/1.0.13/_extend.d.ts +0 -4
  285. package/script/deps/jsr.io/@std/expect/1.0.13/_extend.d.ts.map +0 -1
  286. package/script/deps/jsr.io/@std/expect/1.0.13/_extend.js +0 -15
  287. package/script/deps/jsr.io/@std/expect/1.0.13/_inspect_args.d.ts +0 -3
  288. package/script/deps/jsr.io/@std/expect/1.0.13/_inspect_args.d.ts.map +0 -1
  289. package/script/deps/jsr.io/@std/expect/1.0.13/_inspect_args.js +0 -17
  290. package/script/deps/jsr.io/@std/expect/1.0.13/_matchers.d.ts +0 -34
  291. package/script/deps/jsr.io/@std/expect/1.0.13/_matchers.d.ts.map +0 -1
  292. package/script/deps/jsr.io/@std/expect/1.0.13/_matchers.js +0 -748
  293. package/script/deps/jsr.io/@std/expect/1.0.13/_mock_util.d.ts +0 -11
  294. package/script/deps/jsr.io/@std/expect/1.0.13/_mock_util.d.ts.map +0 -1
  295. package/script/deps/jsr.io/@std/expect/1.0.13/_mock_util.js +0 -14
  296. package/script/deps/jsr.io/@std/expect/1.0.13/_serializer.d.ts +0 -4
  297. package/script/deps/jsr.io/@std/expect/1.0.13/_serializer.d.ts.map +0 -1
  298. package/script/deps/jsr.io/@std/expect/1.0.13/_serializer.js +0 -14
  299. package/script/deps/jsr.io/@std/expect/1.0.13/_types.d.ts +0 -843
  300. package/script/deps/jsr.io/@std/expect/1.0.13/_types.d.ts.map +0 -1
  301. package/script/deps/jsr.io/@std/expect/1.0.13/_types.js +0 -4
  302. package/script/deps/jsr.io/@std/expect/1.0.13/_utils.d.ts +0 -9
  303. package/script/deps/jsr.io/@std/expect/1.0.13/_utils.d.ts.map +0 -1
  304. package/script/deps/jsr.io/@std/expect/1.0.13/_utils.js +0 -226
  305. package/script/deps/jsr.io/@std/expect/1.0.13/expect.d.ts +0 -60
  306. package/script/deps/jsr.io/@std/expect/1.0.13/expect.d.ts.map +0 -1
  307. package/script/deps/jsr.io/@std/expect/1.0.13/expect.js +0 -527
  308. package/script/deps/jsr.io/@std/internal/1.0.5/assertion_state.d.ts +0 -160
  309. package/script/deps/jsr.io/@std/internal/1.0.5/assertion_state.d.ts.map +0 -1
  310. package/script/deps/jsr.io/@std/internal/1.0.5/assertion_state.js +0 -204
  311. package/script/deps/jsr.io/@std/internal/1.0.5/build_message.d.ts +0 -82
  312. package/script/deps/jsr.io/@std/internal/1.0.5/build_message.d.ts.map +0 -1
  313. package/script/deps/jsr.io/@std/internal/1.0.5/build_message.js +0 -116
  314. package/script/deps/jsr.io/@std/internal/1.0.5/diff.d.ts +0 -140
  315. package/script/deps/jsr.io/@std/internal/1.0.5/diff.d.ts.map +0 -1
  316. package/script/deps/jsr.io/@std/internal/1.0.5/diff.js +0 -284
  317. package/script/deps/jsr.io/@std/internal/1.0.5/diff_str.d.ts +0 -99
  318. package/script/deps/jsr.io/@std/internal/1.0.5/diff_str.d.ts.map +0 -1
  319. package/script/deps/jsr.io/@std/internal/1.0.5/diff_str.js +0 -186
  320. package/script/deps/jsr.io/@std/internal/1.0.5/format.d.ts +0 -2
  321. package/script/deps/jsr.io/@std/internal/1.0.5/format.d.ts.map +0 -1
  322. package/script/deps/jsr.io/@std/internal/1.0.5/format.js +0 -41
  323. package/script/deps/jsr.io/@std/internal/1.0.5/styles.d.ts +0 -159
  324. package/script/deps/jsr.io/@std/internal/1.0.5/styles.d.ts.map +0 -1
  325. package/script/deps/jsr.io/@std/internal/1.0.5/styles.js +0 -220
  326. package/script/deps/jsr.io/@std/internal/1.0.5/types.d.ts +0 -16
  327. package/script/deps/jsr.io/@std/internal/1.0.5/types.d.ts.map +0 -1
  328. package/script/deps/jsr.io/@std/internal/1.0.5/types.js +0 -3
  329. package/script/deps/jsr.io/@std/testing/1.0.9/_mock_utils.d.ts +0 -15
  330. package/script/deps/jsr.io/@std/testing/1.0.9/_mock_utils.d.ts.map +0 -1
  331. package/script/deps/jsr.io/@std/testing/1.0.9/_mock_utils.js +0 -41
  332. package/script/deps/jsr.io/@std/testing/1.0.9/_test_suite.d.ts +0 -79
  333. package/script/deps/jsr.io/@std/testing/1.0.9/_test_suite.d.ts.map +0 -1
  334. package/script/deps/jsr.io/@std/testing/1.0.9/_test_suite.js +0 -385
  335. package/script/deps/jsr.io/@std/testing/1.0.9/bdd.d.ts +0 -738
  336. package/script/deps/jsr.io/@std/testing/1.0.9/bdd.d.ts.map +0 -1
  337. package/script/deps/jsr.io/@std/testing/1.0.9/bdd.js +0 -665
  338. package/script/deps/jsr.io/@std/testing/1.0.9/mock.d.ts +0 -674
  339. package/script/deps/jsr.io/@std/testing/1.0.9/mock.d.ts.map +0 -1
  340. package/script/deps/jsr.io/@std/testing/1.0.9/mock.js +0 -1102
  341. package/script/src/ast/nodes/annotation.test.d.ts +0 -2
  342. package/script/src/ast/nodes/annotation.test.d.ts.map +0 -1
  343. package/script/src/ast/nodes/annotation.test.js +0 -58
  344. package/script/src/ast/nodes/argument.test.d.ts +0 -2
  345. package/script/src/ast/nodes/argument.test.d.ts.map +0 -1
  346. package/script/src/ast/nodes/argument.test.js +0 -35
  347. package/script/src/ast/nodes/call.test.d.ts +0 -2
  348. package/script/src/ast/nodes/call.test.d.ts.map +0 -1
  349. package/script/src/ast/nodes/call.test.js +0 -37
  350. package/script/src/ast/nodes/class.test.d.ts +0 -2
  351. package/script/src/ast/nodes/class.test.d.ts.map +0 -1
  352. package/script/src/ast/nodes/class.test.js +0 -221
  353. package/script/src/ast/nodes/constructor.test.d.ts +0 -2
  354. package/script/src/ast/nodes/constructor.test.d.ts.map +0 -1
  355. package/script/src/ast/nodes/constructor.test.js +0 -141
  356. package/script/src/ast/nodes/doc-tag.test.d.ts +0 -2
  357. package/script/src/ast/nodes/doc-tag.test.d.ts.map +0 -1
  358. package/script/src/ast/nodes/doc-tag.test.js +0 -69
  359. package/script/src/ast/nodes/doc.test.d.ts +0 -2
  360. package/script/src/ast/nodes/doc.test.d.ts.map +0 -1
  361. package/script/src/ast/nodes/doc.test.js +0 -35
  362. package/script/src/ast/nodes/enum-value.test.d.ts +0 -2
  363. package/script/src/ast/nodes/enum-value.test.d.ts.map +0 -1
  364. package/script/src/ast/nodes/enum-value.test.js +0 -117
  365. package/script/src/ast/nodes/enum.test.d.ts +0 -2
  366. package/script/src/ast/nodes/enum.test.d.ts.map +0 -1
  367. package/script/src/ast/nodes/enum.test.js +0 -131
  368. package/script/src/ast/nodes/function.test.d.ts +0 -2
  369. package/script/src/ast/nodes/function.test.d.ts.map +0 -1
  370. package/script/src/ast/nodes/function.test.js +0 -162
  371. package/script/src/ast/nodes/generic-parameter.test.d.ts +0 -2
  372. package/script/src/ast/nodes/generic-parameter.test.d.ts.map +0 -1
  373. package/script/src/ast/nodes/generic-parameter.test.js +0 -51
  374. package/script/src/ast/nodes/init-block.test.d.ts +0 -2
  375. package/script/src/ast/nodes/init-block.test.d.ts.map +0 -1
  376. package/script/src/ast/nodes/init-block.test.js +0 -30
  377. package/script/src/ast/nodes/interface.test.d.ts +0 -2
  378. package/script/src/ast/nodes/interface.test.d.ts.map +0 -1
  379. package/script/src/ast/nodes/interface.test.js +0 -123
  380. package/script/src/ast/nodes/object.test.d.ts +0 -2
  381. package/script/src/ast/nodes/object.test.d.ts.map +0 -1
  382. package/script/src/ast/nodes/object.test.js +0 -80
  383. package/script/src/ast/nodes/parameter.test.d.ts +0 -2
  384. package/script/src/ast/nodes/parameter.test.d.ts.map +0 -1
  385. package/script/src/ast/nodes/parameter.test.js +0 -154
  386. package/script/src/ast/nodes/property.test.d.ts +0 -2
  387. package/script/src/ast/nodes/property.test.d.ts.map +0 -1
  388. package/script/src/ast/nodes/property.test.js +0 -208
  389. package/script/src/ast/nodes/reference.test.d.ts +0 -2
  390. package/script/src/ast/nodes/reference.test.d.ts.map +0 -1
  391. package/script/src/ast/nodes/reference.test.js +0 -38
  392. package/script/src/ast/nodes/string.test.d.ts +0 -2
  393. package/script/src/ast/nodes/string.test.d.ts.map +0 -1
  394. package/script/src/ast/nodes/string.test.js +0 -50
  395. package/script/src/import-collection.test.d.ts +0 -2
  396. package/script/src/import-collection.test.d.ts.map +0 -1
  397. package/script/src/import-collection.test.js +0 -101
  398. package/script/tests/openapi-models.test.d.ts +0 -2
  399. package/script/tests/openapi-models.test.d.ts.map +0 -1
  400. package/script/tests/openapi-models.test.js +0 -48
  401. package/src/_dnt.test_polyfills.ts +0 -70
  402. package/src/_dnt.test_shims.ts +0 -64
  403. package/src/deps/jsr.io/@std/assert/1.0.11/assertion_error.ts +0 -31
  404. package/src/deps/jsr.io/@std/assert/1.0.11/equal.ts +0 -210
  405. package/src/deps/jsr.io/@std/assert/1.0.11/equals.ts +0 -65
  406. package/src/deps/jsr.io/@std/assert/1.0.11/false.ts +0 -26
  407. package/src/deps/jsr.io/@std/assert/1.0.11/instance_of.ts +0 -64
  408. package/src/deps/jsr.io/@std/assert/1.0.11/is_error.ts +0 -65
  409. package/src/deps/jsr.io/@std/assert/1.0.11/match.ts +0 -30
  410. package/src/deps/jsr.io/@std/assert/1.0.11/not_instance_of.ts +0 -33
  411. package/src/deps/jsr.io/@std/assert/1.0.11/not_match.ts +0 -30
  412. package/src/deps/jsr.io/@std/assert/1.0.11/not_strict_equals.ts +0 -42
  413. package/src/deps/jsr.io/@std/assert/1.0.11/rejects.ts +0 -123
  414. package/src/deps/jsr.io/@std/assert/1.0.11/strict_equals.ts +0 -67
  415. package/src/deps/jsr.io/@std/expect/1.0.13/_assert_equals.ts +0 -38
  416. package/src/deps/jsr.io/@std/expect/1.0.13/_assert_is_error.ts +0 -54
  417. package/src/deps/jsr.io/@std/expect/1.0.13/_assert_not_equals.ts +0 -35
  418. package/src/deps/jsr.io/@std/expect/1.0.13/_assertions.ts +0 -18
  419. package/src/deps/jsr.io/@std/expect/1.0.13/_asymmetric_matchers.ts +0 -198
  420. package/src/deps/jsr.io/@std/expect/1.0.13/_build_message.ts +0 -51
  421. package/src/deps/jsr.io/@std/expect/1.0.13/_custom_equality_tester.ts +0 -19
  422. package/src/deps/jsr.io/@std/expect/1.0.13/_equal.ts +0 -230
  423. package/src/deps/jsr.io/@std/expect/1.0.13/_extend.ts +0 -16
  424. package/src/deps/jsr.io/@std/expect/1.0.13/_inspect_args.ts +0 -15
  425. package/src/deps/jsr.io/@std/expect/1.0.13/_matchers.ts +0 -1028
  426. package/src/deps/jsr.io/@std/expect/1.0.13/_mock_util.ts +0 -22
  427. package/src/deps/jsr.io/@std/expect/1.0.13/_serializer.ts +0 -15
  428. package/src/deps/jsr.io/@std/expect/1.0.13/_types.ts +0 -923
  429. package/src/deps/jsr.io/@std/expect/1.0.13/_utils.ts +0 -283
  430. package/src/deps/jsr.io/@std/expect/1.0.13/expect.ts +0 -620
  431. package/src/deps/jsr.io/@std/internal/1.0.5/assertion_state.ts +0 -214
  432. package/src/deps/jsr.io/@std/internal/1.0.5/build_message.ts +0 -134
  433. package/src/deps/jsr.io/@std/internal/1.0.5/diff.ts +0 -317
  434. package/src/deps/jsr.io/@std/internal/1.0.5/diff_str.ts +0 -204
  435. package/src/deps/jsr.io/@std/internal/1.0.5/format.ts +0 -39
  436. package/src/deps/jsr.io/@std/internal/1.0.5/styles.ts +0 -233
  437. package/src/deps/jsr.io/@std/internal/1.0.5/types.ts +0 -18
  438. package/src/deps/jsr.io/@std/testing/1.0.9/_mock_utils.ts +0 -43
  439. package/src/deps/jsr.io/@std/testing/1.0.9/_test_suite.ts +0 -448
  440. package/src/deps/jsr.io/@std/testing/1.0.9/bdd.ts +0 -1288
  441. package/src/deps/jsr.io/@std/testing/1.0.9/mock.ts +0 -1807
  442. package/src/mod.ts +0 -8
  443. package/src/src/assets.ts +0 -9
  444. package/src/src/ast/_index.ts +0 -66
  445. package/src/src/ast/common.ts +0 -1
  446. package/src/src/ast/index.ts +0 -1
  447. package/src/src/ast/node.ts +0 -10
  448. package/src/src/ast/nodes/annotation.test.ts +0 -69
  449. package/src/src/ast/nodes/annotation.ts +0 -79
  450. package/src/src/ast/nodes/argument.test.ts +0 -41
  451. package/src/src/ast/nodes/argument.ts +0 -62
  452. package/src/src/ast/nodes/call.test.ts +0 -44
  453. package/src/src/ast/nodes/call.ts +0 -66
  454. package/src/src/ast/nodes/class.test.ts +0 -274
  455. package/src/src/ast/nodes/class.ts +0 -178
  456. package/src/src/ast/nodes/collection-literal.ts +0 -49
  457. package/src/src/ast/nodes/constructor.test.ts +0 -178
  458. package/src/src/ast/nodes/constructor.ts +0 -126
  459. package/src/src/ast/nodes/doc-tag.test.ts +0 -84
  460. package/src/src/ast/nodes/doc-tag.ts +0 -138
  461. package/src/src/ast/nodes/doc.test.ts +0 -42
  462. package/src/src/ast/nodes/doc.ts +0 -111
  463. package/src/src/ast/nodes/enum-value.test.ts +0 -146
  464. package/src/src/ast/nodes/enum-value.ts +0 -100
  465. package/src/src/ast/nodes/enum.test.ts +0 -167
  466. package/src/src/ast/nodes/enum.ts +0 -163
  467. package/src/src/ast/nodes/function.test.ts +0 -194
  468. package/src/src/ast/nodes/function.ts +0 -176
  469. package/src/src/ast/nodes/generic-parameter.test.ts +0 -60
  470. package/src/src/ast/nodes/generic-parameter.ts +0 -54
  471. package/src/src/ast/nodes/init-block.test.ts +0 -36
  472. package/src/src/ast/nodes/init-block.ts +0 -38
  473. package/src/src/ast/nodes/interface.test.ts +0 -151
  474. package/src/src/ast/nodes/interface.ts +0 -133
  475. package/src/src/ast/nodes/lambda-type.ts +0 -68
  476. package/src/src/ast/nodes/lambda.ts +0 -68
  477. package/src/src/ast/nodes/object.test.ts +0 -101
  478. package/src/src/ast/nodes/object.ts +0 -102
  479. package/src/src/ast/nodes/parameter.test.ts +0 -191
  480. package/src/src/ast/nodes/parameter.ts +0 -118
  481. package/src/src/ast/nodes/property.test.ts +0 -253
  482. package/src/src/ast/nodes/property.ts +0 -225
  483. package/src/src/ast/nodes/reference.test.ts +0 -47
  484. package/src/src/ast/nodes/reference.ts +0 -178
  485. package/src/src/ast/nodes/string.test.ts +0 -61
  486. package/src/src/ast/nodes/string.ts +0 -114
  487. package/src/src/ast/nodes/types.ts +0 -23
  488. package/src/src/ast/references/index.ts +0 -8
  489. package/src/src/ast/references/jackson.ts +0 -16
  490. package/src/src/ast/references/jakarta.ts +0 -10
  491. package/src/src/ast/references/java.ts +0 -19
  492. package/src/src/ast/references/kotlin.ts +0 -40
  493. package/src/src/ast/references/okhttp3.ts +0 -5
  494. package/src/src/ast/references/reactor.ts +0 -5
  495. package/src/src/ast/references/spring.ts +0 -68
  496. package/src/src/ast/references/swagger.ts +0 -23
  497. package/src/src/ast/utils/get-kotlin-builder-options.ts +0 -19
  498. package/src/src/ast/utils/to-kt-node.ts +0 -31
  499. package/src/src/ast/utils/write-kt-annotations.ts +0 -15
  500. package/src/src/ast/utils/write-kt-arguments.ts +0 -45
  501. package/src/src/ast/utils/write-kt-enum-values.ts +0 -27
  502. package/src/src/ast/utils/write-kt-generic-parameters.ts +0 -12
  503. package/src/src/ast/utils/write-kt-members.ts +0 -25
  504. package/src/src/ast/utils/write-kt-node.ts +0 -37
  505. package/src/src/ast/utils/write-kt-parameters.ts +0 -25
  506. package/src/src/common-results.ts +0 -4
  507. package/src/src/config.ts +0 -41
  508. package/src/src/file-builder.ts +0 -108
  509. package/src/src/generators/file-generator.ts +0 -29
  510. package/src/src/generators/index.ts +0 -4
  511. package/src/src/generators/models/args.ts +0 -128
  512. package/src/src/generators/models/index.ts +0 -4
  513. package/src/src/generators/models/model-generator.ts +0 -602
  514. package/src/src/generators/models/models-generator.ts +0 -65
  515. package/src/src/generators/models/models.ts +0 -95
  516. package/src/src/generators/services/okhttp3-clients/args.ts +0 -78
  517. package/src/src/generators/services/okhttp3-clients/index.ts +0 -4
  518. package/src/src/generators/services/okhttp3-clients/models.ts +0 -62
  519. package/src/src/generators/services/okhttp3-clients/okhttp3-client-generator.ts +0 -557
  520. package/src/src/generators/services/okhttp3-clients/okhttp3-clients-generator.ts +0 -130
  521. package/src/src/generators/services/okhttp3-clients/refs.ts +0 -55
  522. package/src/src/generators/services/spring-controllers/args.ts +0 -88
  523. package/src/src/generators/services/spring-controllers/index.ts +0 -4
  524. package/src/src/generators/services/spring-controllers/models.ts +0 -66
  525. package/src/src/generators/services/spring-controllers/spring-controller-generator.ts +0 -763
  526. package/src/src/generators/services/spring-controllers/spring-controllers-generator.ts +0 -70
  527. package/src/src/import-collection.test.ts +0 -116
  528. package/src/src/import-collection.ts +0 -98
  529. package/src/src/types.ts +0 -3
  530. package/src/src/utils.ts +0 -39
  531. package/src/tests/openapi-models.test.ts +0 -63
  532. package/test_runner.js +0 -227
@@ -1,1102 +0,0 @@
1
- "use strict";
2
- // Copyright 2018-2025 the Deno authors. MIT license.
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.MockError = void 0;
5
- exports.mockSession = mockSession;
6
- exports.mockSessionAsync = mockSessionAsync;
7
- exports.restore = restore;
8
- exports.spy = spy;
9
- exports.stub = stub;
10
- exports.assertSpyCalls = assertSpyCalls;
11
- exports.assertSpyCall = assertSpyCall;
12
- exports.assertSpyCallAsync = assertSpyCallAsync;
13
- exports.assertSpyCallArg = assertSpyCallArg;
14
- exports.assertSpyCallArgs = assertSpyCallArgs;
15
- exports.returnsThis = returnsThis;
16
- exports.returnsArg = returnsArg;
17
- exports.returnsArgs = returnsArgs;
18
- exports.returnsNext = returnsNext;
19
- exports.resolvesNext = resolvesNext;
20
- const tslib_1 = require("tslib");
21
- /** A mocking and spying library.
22
- *
23
- * Test spies are function stand-ins that are used to assert if a function's
24
- * internal behavior matches expectations. Test spies on methods keep the original
25
- * behavior but allow you to test how the method is called and what it returns.
26
- * Test stubs are an extension of test spies that also replaces the original
27
- * methods behavior.
28
- *
29
- * ## Spying
30
- *
31
- * Say we have two functions, `square` and `multiply`, if we want to assert that
32
- * the `multiply` function is called during execution of the `square` function we
33
- * need a way to spy on the `multiply` function. There are a few ways to achieve
34
- * this with Spies, one is to have the `square` function take the `multiply`
35
- * multiply as a parameter.
36
- *
37
- * This way, we can call `square(multiply, value)` in the application code or wrap
38
- * a spy function around the `multiply` function and call
39
- * `square(multiplySpy, value)` in the testing code.
40
- *
41
- * ```ts
42
- * import {
43
- * assertSpyCall,
44
- * assertSpyCalls,
45
- * spy,
46
- * } from "@std/testing/mock";
47
- * import { assertEquals } from "@std/assert";
48
- *
49
- * function multiply(a: number, b: number): number {
50
- * return a * b;
51
- * }
52
- *
53
- * function square(
54
- * multiplyFn: (a: number, b: number) => number,
55
- * value: number,
56
- * ): number {
57
- * return multiplyFn(value, value);
58
- * }
59
- *
60
- * Deno.test("square calls multiply and returns results", () => {
61
- * const multiplySpy = spy(multiply);
62
- *
63
- * assertEquals(square(multiplySpy, 5), 25);
64
- *
65
- * // asserts that multiplySpy was called at least once and details about the first call.
66
- * assertSpyCall(multiplySpy, 0, {
67
- * args: [5, 5],
68
- * returned: 25,
69
- * });
70
- *
71
- * // asserts that multiplySpy was only called once.
72
- * assertSpyCalls(multiplySpy, 1);
73
- * });
74
- * ```
75
- *
76
- * If you prefer not adding additional parameters for testing purposes only, you
77
- * can use spy to wrap a method on an object instead. In the following example, the
78
- * exported `_internals` object has the `multiply` function we want to call as a
79
- * method and the `square` function calls `_internals.multiply` instead of
80
- * `multiply`.
81
- *
82
- * This way, we can call `square(value)` in both the application code and testing
83
- * code. Then spy on the `multiply` method on the `_internals` object in the
84
- * testing code to be able to spy on how the `square` function calls the `multiply`
85
- * function.
86
- *
87
- * ```ts
88
- * import {
89
- * assertSpyCall,
90
- * assertSpyCalls,
91
- * spy,
92
- * } from "@std/testing/mock";
93
- * import { assertEquals } from "@std/assert";
94
- *
95
- * function multiply(a: number, b: number): number {
96
- * return a * b;
97
- * }
98
- *
99
- * function square(value: number): number {
100
- * return _internals.multiply(value, value);
101
- * }
102
- *
103
- * const _internals = { multiply };
104
- *
105
- * Deno.test("square calls multiply and returns results", () => {
106
- * const multiplySpy = spy(_internals, "multiply");
107
- *
108
- * try {
109
- * assertEquals(square(5), 25);
110
- * } finally {
111
- * // unwraps the multiply method on the _internals object
112
- * multiplySpy.restore();
113
- * }
114
- *
115
- * // asserts that multiplySpy was called at least once and details about the first call.
116
- * assertSpyCall(multiplySpy, 0, {
117
- * args: [5, 5],
118
- * returned: 25,
119
- * });
120
- *
121
- * // asserts that multiplySpy was only called once.
122
- * assertSpyCalls(multiplySpy, 1);
123
- * });
124
- * ```
125
- *
126
- * One difference you may have noticed between these two examples is that in the
127
- * second we call the `restore` method on `multiplySpy` function. That is needed to
128
- * remove the spy wrapper from the `_internals` object's `multiply` method. The
129
- * `restore` method is called in a finally block to ensure that it is restored
130
- * whether or not the assertion in the try block is successful. The `restore`
131
- * method didn't need to be called in the first example because the `multiply`
132
- * function was not modified in any way like the `_internals` object was in the
133
- * second example.
134
- *
135
- * Method spys are disposable, meaning that you can have them automatically restore
136
- * themselves with the `using` keyword. Using this approach is cleaner because you
137
- * do not need to wrap your assertions in a try statement to ensure you restore the
138
- * methods before the tests finish.
139
- *
140
- * ```ts
141
- * import {
142
- * assertSpyCall,
143
- * assertSpyCalls,
144
- * spy,
145
- * } from "@std/testing/mock";
146
- * import { assertEquals } from "@std/assert";
147
- *
148
- * function multiply(a: number, b: number): number {
149
- * return a * b;
150
- * }
151
- *
152
- * function square(value: number): number {
153
- * return _internals.multiply(value, value);
154
- * }
155
- *
156
- * const _internals = { multiply };
157
- *
158
- * Deno.test("square calls multiply and returns results", () => {
159
- * using multiplySpy = spy(_internals, "multiply");
160
- *
161
- * assertEquals(square(5), 25);
162
- *
163
- * // asserts that multiplySpy was called at least once and details about the first call.
164
- * assertSpyCall(multiplySpy, 0, {
165
- * args: [5, 5],
166
- * returned: 25,
167
- * });
168
- *
169
- * // asserts that multiplySpy was only called once.
170
- * assertSpyCalls(multiplySpy, 1);
171
- * });
172
- * ```
173
- *
174
- * ## Stubbing
175
- *
176
- * Say we have two functions, `randomMultiple` and `randomInt`, if we want to
177
- * assert that `randomInt` is called during execution of `randomMultiple` we need a
178
- * way to spy on the `randomInt` function. That could be done with either of the
179
- * spying techniques previously mentioned. To be able to verify that the
180
- * `randomMultiple` function returns the value we expect it to for what `randomInt`
181
- * returns, the easiest way would be to replace the `randomInt` function's behavior
182
- * with more predictable behavior.
183
- *
184
- * You could use the first spying technique to do that but that would require
185
- * adding a `randomInt` parameter to the `randomMultiple` function.
186
- *
187
- * You could also use the second spying technique to do that, but your assertions
188
- * would not be as predictable due to the `randomInt` function returning random
189
- * values.
190
- *
191
- * Say we want to verify it returns correct values for both negative and positive
192
- * random integers. We could easily do that with stubbing. The below example is
193
- * similar to the second spying technique example but instead of passing the call
194
- * through to the original `randomInt` function, we are going to replace
195
- * `randomInt` with a function that returns pre-defined values.
196
- *
197
- * The mock module includes some helper functions to make creating common stubs
198
- * easy. The `returnsNext` function takes an array of values we want it to return
199
- * on consecutive calls.
200
- *
201
- * ```ts
202
- * import {
203
- * assertSpyCall,
204
- * assertSpyCalls,
205
- * returnsNext,
206
- * stub,
207
- * } from "@std/testing/mock";
208
- * import { assertEquals } from "@std/assert";
209
- *
210
- * function randomInt(lowerBound: number, upperBound: number): number {
211
- * return lowerBound + Math.floor(Math.random() * (upperBound - lowerBound));
212
- * }
213
- *
214
- * function randomMultiple(value: number): number {
215
- * return value * _internals.randomInt(-10, 10);
216
- * }
217
- *
218
- * const _internals = { randomInt };
219
- *
220
- * Deno.test("randomMultiple uses randomInt to generate random multiples between -10 and 10 times the value", () => {
221
- * const randomIntStub = stub(_internals, "randomInt", returnsNext([-3, 3]));
222
- *
223
- * try {
224
- * assertEquals(randomMultiple(5), -15);
225
- * assertEquals(randomMultiple(5), 15);
226
- * } finally {
227
- * // unwraps the randomInt method on the _internals object
228
- * randomIntStub.restore();
229
- * }
230
- *
231
- * // asserts that randomIntStub was called at least once and details about the first call.
232
- * assertSpyCall(randomIntStub, 0, {
233
- * args: [-10, 10],
234
- * returned: -3,
235
- * });
236
- * // asserts that randomIntStub was called at least twice and details about the second call.
237
- * assertSpyCall(randomIntStub, 1, {
238
- * args: [-10, 10],
239
- * returned: 3,
240
- * });
241
- *
242
- * // asserts that randomIntStub was only called twice.
243
- * assertSpyCalls(randomIntStub, 2);
244
- * });
245
- * ```
246
- *
247
- * Like method spys, stubs are disposable, meaning that you can have them automatically
248
- * restore themselves with the `using` keyword. Using this approach is cleaner because
249
- * you do not need to wrap your assertions in a try statement to ensure you restore the
250
- * methods before the tests finish.
251
- *
252
- * ```ts
253
- * import {
254
- * assertSpyCall,
255
- * assertSpyCalls,
256
- * returnsNext,
257
- * stub,
258
- * } from "@std/testing/mock";
259
- * import { assertEquals } from "@std/assert";
260
- *
261
- * function randomInt(lowerBound: number, upperBound: number): number {
262
- * return lowerBound + Math.floor(Math.random() * (upperBound - lowerBound));
263
- * }
264
- *
265
- * function randomMultiple(value: number): number {
266
- * return value * _internals.randomInt(-10, 10);
267
- * }
268
- *
269
- * const _internals = { randomInt };
270
- *
271
- * Deno.test("randomMultiple uses randomInt to generate random multiples between -10 and 10 times the value", () => {
272
- * using randomIntStub = stub(_internals, "randomInt", returnsNext([-3, 3]));
273
- *
274
- * assertEquals(randomMultiple(5), -15);
275
- * assertEquals(randomMultiple(5), 15);
276
- *
277
- * // asserts that randomIntStub was called at least once and details about the first call.
278
- * assertSpyCall(randomIntStub, 0, {
279
- * args: [-10, 10],
280
- * returned: -3,
281
- * });
282
- * // asserts that randomIntStub was called at least twice and details about the second call.
283
- * assertSpyCall(randomIntStub, 1, {
284
- * args: [-10, 10],
285
- * returned: 3,
286
- * });
287
- *
288
- * // asserts that randomIntStub was only called twice.
289
- * assertSpyCalls(randomIntStub, 2);
290
- * });
291
- * ```
292
- *
293
- * ## Faking time
294
- *
295
- * Say we have a function that has time based behavior that we would like to test.
296
- * With real time, that could cause tests to take much longer than they should. If
297
- * you fake time, you could simulate how your function would behave over time
298
- * starting from any point in time. Below is an example where we want to test that
299
- * the callback is called every second.
300
- *
301
- * With `FakeTime` we can do that. When the `FakeTime` instance is created, it
302
- * splits from real time. The `Date`, `setTimeout`, `clearTimeout`, `setInterval`
303
- * and `clearInterval` globals are replaced with versions that use the fake time
304
- * until real time is restored. You can control how time ticks forward with the
305
- * `tick` method on the `FakeTime` instance.
306
- *
307
- * ```ts
308
- * import {
309
- * assertSpyCalls,
310
- * spy,
311
- * } from "@std/testing/mock";
312
- * import { FakeTime } from "@std/testing/time";
313
- *
314
- * function secondInterval(cb: () => void): number {
315
- * return setInterval(cb, 1000);
316
- * }
317
- *
318
- * Deno.test("secondInterval calls callback every second and stops after being cleared", () => {
319
- * using time = new FakeTime();
320
- *
321
- * const cb = spy();
322
- * const intervalId = secondInterval(cb);
323
- * assertSpyCalls(cb, 0);
324
- * time.tick(500);
325
- * assertSpyCalls(cb, 0);
326
- * time.tick(500);
327
- * assertSpyCalls(cb, 1);
328
- * time.tick(3500);
329
- * assertSpyCalls(cb, 4);
330
- *
331
- * clearInterval(intervalId);
332
- * time.tick(1000);
333
- * assertSpyCalls(cb, 4);
334
- * });
335
- * ```
336
- *
337
- * @module
338
- */
339
- const equals_js_1 = require("../../assert/1.0.11/equals.js");
340
- const is_error_js_1 = require("../../assert/1.0.11/is_error.js");
341
- const rejects_js_1 = require("../../assert/1.0.11/rejects.js");
342
- const assertion_error_js_1 = require("../../assert/1.0.11/assertion_error.js");
343
- const _mock_utils_js_1 = require("./_mock_utils.js");
344
- /**
345
- * An error related to spying on a function or instance method.
346
- *
347
- * @example Usage
348
- * ```ts
349
- * import { MockError, spy } from "@std/testing/mock";
350
- * import { assertThrows } from "@std/assert";
351
- *
352
- * assertThrows(() => {
353
- * spy({} as any, "no-such-method");
354
- * }, MockError);
355
- * ```
356
- */
357
- class MockError extends Error {
358
- /**
359
- * Construct MockError
360
- *
361
- * @param message The error message.
362
- */
363
- constructor(message) {
364
- super(message);
365
- this.name = "MockError";
366
- }
367
- }
368
- exports.MockError = MockError;
369
- /** Wraps a function with a Spy. */
370
- function functionSpy(func) {
371
- const original = func !== null && func !== void 0 ? func : (() => { });
372
- const calls = [];
373
- const spy = function (...args) {
374
- const call = { args };
375
- if (this)
376
- call.self = this;
377
- try {
378
- call.returned = original.apply(this, args);
379
- }
380
- catch (error) {
381
- call.error = error;
382
- calls.push(call);
383
- throw error;
384
- }
385
- calls.push(call);
386
- return call.returned;
387
- };
388
- Object.defineProperties(spy, {
389
- original: {
390
- enumerable: true,
391
- value: original,
392
- },
393
- calls: {
394
- enumerable: true,
395
- value: calls,
396
- },
397
- restored: {
398
- enumerable: true,
399
- get: () => false,
400
- },
401
- restore: {
402
- enumerable: true,
403
- value: () => {
404
- throw new MockError("Cannot restore: function cannot be restored");
405
- },
406
- },
407
- });
408
- return spy;
409
- }
410
- function mockSession(func) {
411
- if (func) {
412
- return function (...args) {
413
- const id = _mock_utils_js_1.sessions.length;
414
- _mock_utils_js_1.sessions.push(new Set());
415
- try {
416
- return func.apply(this, args);
417
- }
418
- finally {
419
- restore(id);
420
- }
421
- };
422
- }
423
- else {
424
- _mock_utils_js_1.sessions.push(new Set());
425
- return _mock_utils_js_1.sessions.length - 1;
426
- }
427
- }
428
- /**
429
- * Creates an async session that tracks all mocks created before the promise resolves.
430
- *
431
- * @example Usage
432
- * ```ts
433
- * import { mockSessionAsync, restore, stub } from "@std/testing/mock";
434
- * import { assertEquals, assertNotEquals } from "@std/assert";
435
- *
436
- * const setTimeout = globalThis.setTimeout;
437
- * const session = mockSessionAsync(async () => {
438
- * stub(globalThis, "setTimeout");
439
- * assertNotEquals(globalThis.setTimeout, setTimeout);
440
- * });
441
- *
442
- * await session();
443
- *
444
- * assertEquals(globalThis.setTimeout, setTimeout); // stub is restored
445
- * ```
446
- * @typeParam Self The self type of the function.
447
- * @typeParam Args The arguments type of the function.
448
- * @typeParam Return The return type of the function.
449
- * @param func The function.
450
- * @returns The return value of the function.
451
- */
452
- function mockSessionAsync(func) {
453
- return async function (...args) {
454
- const id = _mock_utils_js_1.sessions.length;
455
- _mock_utils_js_1.sessions.push(new Set());
456
- try {
457
- return await func.apply(this, args);
458
- }
459
- finally {
460
- restore(id);
461
- }
462
- };
463
- }
464
- /**
465
- * Restores all mocks registered in the current session that have not already been restored.
466
- * If an id is provided, it will restore all mocks registered in the session associed with that id that have not already been restored.
467
- *
468
- * @example Usage
469
- * ```ts
470
- * import { mockSession, restore, stub } from "@std/testing/mock";
471
- * import { assertEquals, assertNotEquals } from "@std/assert";
472
- *
473
- * const setTimeout = globalThis.setTimeout;
474
- *
475
- * stub(globalThis, "setTimeout");
476
- *
477
- * assertNotEquals(globalThis.setTimeout, setTimeout);
478
- *
479
- * restore();
480
- *
481
- * assertEquals(globalThis.setTimeout, setTimeout);
482
- * ```
483
- *
484
- * @param id The id of the session to restore. If not provided, all mocks registered in the current session are restored.
485
- */
486
- function restore(id) {
487
- id !== null && id !== void 0 ? id : (id = (_mock_utils_js_1.sessions.length || 1) - 1);
488
- while (id < _mock_utils_js_1.sessions.length) {
489
- const session = _mock_utils_js_1.sessions.pop();
490
- if (session) {
491
- for (const value of session) {
492
- value.restore();
493
- }
494
- }
495
- }
496
- }
497
- /** Wraps an instance method with a Spy. */
498
- function methodSpy(self, property) {
499
- var _a, _b;
500
- if (typeof self[property] !== "function") {
501
- throw new MockError("Cannot spy: property is not an instance method");
502
- }
503
- if ((0, _mock_utils_js_1.isSpy)(self[property])) {
504
- throw new MockError("Cannot spy: already spying on instance method");
505
- }
506
- const propertyDescriptor = Object.getOwnPropertyDescriptor(self, property);
507
- if (propertyDescriptor && !propertyDescriptor.configurable) {
508
- throw new MockError("Cannot spy: non-configurable instance method");
509
- }
510
- const original = self[property];
511
- const calls = [];
512
- let restored = false;
513
- const spy = function (...args) {
514
- const call = { args };
515
- if (this)
516
- call.self = this;
517
- try {
518
- call.returned = original.apply(this, args);
519
- }
520
- catch (error) {
521
- call.error = error;
522
- calls.push(call);
523
- throw error;
524
- }
525
- calls.push(call);
526
- return call.returned;
527
- };
528
- Object.defineProperties(spy, {
529
- original: {
530
- enumerable: true,
531
- value: original,
532
- },
533
- calls: {
534
- enumerable: true,
535
- value: calls,
536
- },
537
- restored: {
538
- enumerable: true,
539
- get: () => restored,
540
- },
541
- restore: {
542
- enumerable: true,
543
- value: () => {
544
- if (restored) {
545
- throw new MockError("Cannot restore: instance method already restored");
546
- }
547
- if (propertyDescriptor) {
548
- Object.defineProperty(self, property, propertyDescriptor);
549
- }
550
- else {
551
- delete self[property];
552
- }
553
- restored = true;
554
- (0, _mock_utils_js_1.unregisterMock)(spy);
555
- },
556
- },
557
- [Symbol.dispose]: {
558
- value: () => {
559
- spy.restore();
560
- },
561
- },
562
- });
563
- Object.defineProperty(self, property, {
564
- configurable: true,
565
- enumerable: (_a = propertyDescriptor === null || propertyDescriptor === void 0 ? void 0 : propertyDescriptor.enumerable) !== null && _a !== void 0 ? _a : false,
566
- writable: (_b = propertyDescriptor === null || propertyDescriptor === void 0 ? void 0 : propertyDescriptor.writable) !== null && _b !== void 0 ? _b : false,
567
- value: spy,
568
- });
569
- (0, _mock_utils_js_1.registerMock)(spy);
570
- return spy;
571
- }
572
- /** Wraps a constructor with a Spy. */
573
- function constructorSpy(constructor) {
574
- var _a;
575
- const original = constructor;
576
- const calls = [];
577
- // @ts-ignore TS2509: Can't know the type of `original` statically.
578
- const spy = (_a = class extends original {
579
- // deno-lint-ignore constructor-super
580
- constructor(...args) {
581
- const call = { args };
582
- try {
583
- super(...args);
584
- call.returned = this;
585
- }
586
- catch (error) {
587
- call.error = error;
588
- calls.push(call);
589
- throw error;
590
- }
591
- calls.push(call);
592
- }
593
- static restore() {
594
- throw new MockError("Cannot restore: constructor cannot be restored");
595
- }
596
- },
597
- tslib_1.__setFunctionName(_a, "spy"),
598
- Object.defineProperty(_a, "name", {
599
- enumerable: true,
600
- configurable: true,
601
- writable: true,
602
- value: original.name
603
- }),
604
- Object.defineProperty(_a, "original", {
605
- enumerable: true,
606
- configurable: true,
607
- writable: true,
608
- value: original
609
- }),
610
- Object.defineProperty(_a, "calls", {
611
- enumerable: true,
612
- configurable: true,
613
- writable: true,
614
- value: calls
615
- }),
616
- Object.defineProperty(_a, "restored", {
617
- enumerable: true,
618
- configurable: true,
619
- writable: true,
620
- value: false
621
- }),
622
- _a);
623
- return spy;
624
- }
625
- function spy(funcOrConstOrSelf, property) {
626
- if (!funcOrConstOrSelf) {
627
- return functionSpy();
628
- }
629
- else if (property !== undefined) {
630
- return methodSpy(funcOrConstOrSelf, property);
631
- }
632
- else if (funcOrConstOrSelf.toString().startsWith("class")) {
633
- return constructorSpy(funcOrConstOrSelf);
634
- }
635
- else {
636
- return functionSpy(funcOrConstOrSelf);
637
- }
638
- }
639
- function stub(self, property, func) {
640
- var _a, _b;
641
- if (self[property] !== undefined && typeof self[property] !== "function") {
642
- throw new MockError("Cannot stub: property is not an instance method");
643
- }
644
- if ((0, _mock_utils_js_1.isSpy)(self[property])) {
645
- throw new MockError("Cannot stub: already spying on instance method");
646
- }
647
- const propertyDescriptor = Object.getOwnPropertyDescriptor(self, property);
648
- if (propertyDescriptor && !propertyDescriptor.configurable) {
649
- throw new MockError("Cannot stub: non-configurable instance method");
650
- }
651
- const fake = func !== null && func !== void 0 ? func : (() => { });
652
- const original = self[property];
653
- const calls = [];
654
- let restored = false;
655
- const stub = function (...args) {
656
- const call = { args };
657
- if (this)
658
- call.self = this;
659
- try {
660
- call.returned = fake.apply(this, args);
661
- }
662
- catch (error) {
663
- call.error = error;
664
- calls.push(call);
665
- throw error;
666
- }
667
- calls.push(call);
668
- return call.returned;
669
- };
670
- Object.defineProperties(stub, {
671
- original: {
672
- enumerable: true,
673
- value: original,
674
- },
675
- fake: {
676
- enumerable: true,
677
- value: fake,
678
- },
679
- calls: {
680
- enumerable: true,
681
- value: calls,
682
- },
683
- restored: {
684
- enumerable: true,
685
- get: () => restored,
686
- },
687
- restore: {
688
- enumerable: true,
689
- value: () => {
690
- if (restored) {
691
- throw new MockError("Cannot restore: instance method already restored");
692
- }
693
- if (propertyDescriptor) {
694
- Object.defineProperty(self, property, propertyDescriptor);
695
- }
696
- else {
697
- delete self[property];
698
- }
699
- restored = true;
700
- (0, _mock_utils_js_1.unregisterMock)(stub);
701
- },
702
- },
703
- [Symbol.dispose]: {
704
- value: () => {
705
- stub.restore();
706
- },
707
- },
708
- });
709
- Object.defineProperty(self, property, {
710
- configurable: true,
711
- enumerable: (_a = propertyDescriptor === null || propertyDescriptor === void 0 ? void 0 : propertyDescriptor.enumerable) !== null && _a !== void 0 ? _a : false,
712
- writable: (_b = propertyDescriptor === null || propertyDescriptor === void 0 ? void 0 : propertyDescriptor.writable) !== null && _b !== void 0 ? _b : false,
713
- value: stub,
714
- });
715
- (0, _mock_utils_js_1.registerMock)(stub);
716
- return stub;
717
- }
718
- /**
719
- * Asserts that a spy is called as much as expected and no more.
720
- *
721
- * @example Usage
722
- * ```ts
723
- * import { assertSpyCalls, spy } from "@std/testing/mock";
724
- *
725
- * const func = spy();
726
- *
727
- * func();
728
- * func();
729
- *
730
- * assertSpyCalls(func, 2);
731
- * ```
732
- *
733
- * @typeParam Self The self type of the spy function.
734
- * @typeParam Args The arguments type of the spy function.
735
- * @typeParam Return The return type of the spy function.
736
- * @param spy The spy to check
737
- * @param expectedCalls The number of the expected calls.
738
- */
739
- function assertSpyCalls(spy, expectedCalls) {
740
- try {
741
- (0, equals_js_1.assertEquals)(spy.calls.length, expectedCalls);
742
- }
743
- catch (e) {
744
- (0, is_error_js_1.assertIsError)(e);
745
- let message = spy.calls.length < expectedCalls
746
- ? "Spy not called as much as expected:\n"
747
- : "Spy called more than expected:\n";
748
- message += e.message.split("\n").slice(1).join("\n");
749
- throw new assertion_error_js_1.AssertionError(message);
750
- }
751
- }
752
- function getSpyCall(spy, callIndex) {
753
- if (spy.calls.length < (callIndex + 1)) {
754
- throw new assertion_error_js_1.AssertionError("Spy not called as much as expected");
755
- }
756
- return spy.calls[callIndex];
757
- }
758
- /**
759
- * Asserts that a spy is called as expected.
760
- *
761
- * @example Usage
762
- * ```ts
763
- * import { assertSpyCall, spy } from "@std/testing/mock";
764
- *
765
- * const func = spy((a: number, b: number) => a + b);
766
- *
767
- * func(3, 4);
768
- * func(5, 6);
769
- *
770
- * // asserts each call made to the spy function.
771
- * assertSpyCall(func, 0, { args: [3, 4], returned: 7 });
772
- * assertSpyCall(func, 1, { args: [5, 6], returned: 11 });
773
- * ```
774
- *
775
- * @typeParam Self The self type of the spy function.
776
- * @typeParam Args The arguments type of the spy function.
777
- * @typeParam Return The return type of the spy function.
778
- * @param spy The spy to check
779
- * @param callIndex The index of the call to check
780
- * @param expected The expected spy call.
781
- */
782
- function assertSpyCall(spy, callIndex, expected) {
783
- var _a, _b;
784
- const call = getSpyCall(spy, callIndex);
785
- if (expected) {
786
- if (expected.args) {
787
- try {
788
- (0, equals_js_1.assertEquals)(call.args, expected.args);
789
- }
790
- catch (e) {
791
- (0, is_error_js_1.assertIsError)(e);
792
- throw new assertion_error_js_1.AssertionError("Spy not called with expected args:\n" +
793
- e.message.split("\n").slice(1).join("\n"));
794
- }
795
- }
796
- if ("self" in expected) {
797
- try {
798
- (0, equals_js_1.assertEquals)(call.self, expected.self);
799
- }
800
- catch (e) {
801
- (0, is_error_js_1.assertIsError)(e);
802
- let message = expected.self
803
- ? "Spy not called as method on expected self:\n"
804
- : "Spy not expected to be called as method on object:\n";
805
- message += e.message.split("\n").slice(1).join("\n");
806
- throw new assertion_error_js_1.AssertionError(message);
807
- }
808
- }
809
- if ("returned" in expected) {
810
- if ("error" in expected) {
811
- throw new TypeError("Do not expect error and return, only one should be expected");
812
- }
813
- if (call.error) {
814
- throw new assertion_error_js_1.AssertionError("Spy call did not return expected value, an error was thrown.");
815
- }
816
- try {
817
- (0, equals_js_1.assertEquals)(call.returned, expected.returned);
818
- }
819
- catch (e) {
820
- (0, is_error_js_1.assertIsError)(e);
821
- throw new assertion_error_js_1.AssertionError("Spy call did not return expected value:\n" +
822
- e.message.split("\n").slice(1).join("\n"));
823
- }
824
- }
825
- if ("error" in expected) {
826
- if ("returned" in call) {
827
- throw new assertion_error_js_1.AssertionError("Spy call did not throw an error, a value was returned.");
828
- }
829
- (0, is_error_js_1.assertIsError)(call.error, (_a = expected.error) === null || _a === void 0 ? void 0 : _a.Class, (_b = expected.error) === null || _b === void 0 ? void 0 : _b.msgIncludes);
830
- }
831
- }
832
- }
833
- /**
834
- * Asserts that an async spy is called as expected.
835
- *
836
- * @example Usage
837
- * ```ts
838
- * import { assertSpyCallAsync, spy } from "@std/testing/mock";
839
- *
840
- * const func = spy((a: number, b: number) => new Promise((resolve) => {
841
- * setTimeout(() => resolve(a + b), 100)
842
- * }));
843
- *
844
- * await func(3, 4);
845
- * await func(5, 6);
846
- *
847
- * // asserts each call made to the spy function.
848
- * await assertSpyCallAsync(func, 0, { args: [3, 4], returned: 7 });
849
- * await assertSpyCallAsync(func, 1, { args: [5, 6], returned: 11 });
850
- * ```
851
- *
852
- * @typeParam Self The self type of the spy function.
853
- * @typeParam Args The arguments type of the spy function.
854
- * @typeParam Return The return type of the spy function.
855
- * @param spy The spy to check
856
- * @param callIndex The index of the call to check
857
- * @param expected The expected spy call.
858
- */
859
- async function assertSpyCallAsync(spy, callIndex, expected) {
860
- var _a, _b, _c, _d;
861
- const expectedSync = expected && { ...expected };
862
- if (expectedSync) {
863
- delete expectedSync.returned;
864
- delete expectedSync.error;
865
- }
866
- assertSpyCall(spy, callIndex, expectedSync);
867
- const call = getSpyCall(spy, callIndex);
868
- if (call.error) {
869
- throw new assertion_error_js_1.AssertionError("Spy call did not return a promise, an error was thrown.");
870
- }
871
- if (call.returned !== Promise.resolve(call.returned)) {
872
- throw new assertion_error_js_1.AssertionError("Spy call did not return a promise, a value was returned.");
873
- }
874
- if (expected) {
875
- if ("returned" in expected) {
876
- if ("error" in expected) {
877
- throw new TypeError("Do not expect error and return, only one should be expected");
878
- }
879
- let expectedResolved;
880
- try {
881
- expectedResolved = await expected.returned;
882
- }
883
- catch (_e) {
884
- throw new TypeError("Do not expect rejected promise, expect error instead");
885
- }
886
- let resolved;
887
- try {
888
- resolved = await call.returned;
889
- }
890
- catch (_f) {
891
- throw new assertion_error_js_1.AssertionError("Spy call returned promise was rejected");
892
- }
893
- try {
894
- (0, equals_js_1.assertEquals)(resolved, expectedResolved);
895
- }
896
- catch (e) {
897
- (0, is_error_js_1.assertIsError)(e);
898
- throw new assertion_error_js_1.AssertionError("Spy call did not resolve to expected value:\n" +
899
- e.message.split("\n").slice(1).join("\n"));
900
- }
901
- }
902
- if ("error" in expected) {
903
- await (0, rejects_js_1.assertRejects)(() => Promise.resolve(call.returned), (_b = (_a = expected.error) === null || _a === void 0 ? void 0 : _a.Class) !== null && _b !== void 0 ? _b : Error, (_d = (_c = expected.error) === null || _c === void 0 ? void 0 : _c.msgIncludes) !== null && _d !== void 0 ? _d : "");
904
- }
905
- }
906
- }
907
- /**
908
- * Asserts that a spy is called with a specific arg as expected.
909
- *
910
- * @example Usage
911
- * ```ts
912
- * import { assertSpyCallArg, spy } from "@std/testing/mock";
913
- *
914
- * const func = spy((a: number, b: number) => a + b);
915
- *
916
- * func(3, 4);
917
- * func(5, 6);
918
- *
919
- * // asserts each call made to the spy function.
920
- * assertSpyCallArg(func, 0, 0, 3);
921
- * assertSpyCallArg(func, 0, 1, 4);
922
- * assertSpyCallArg(func, 1, 0, 5);
923
- * assertSpyCallArg(func, 1, 1, 6);
924
- * ```
925
- *
926
- * @typeParam Self The self type of the spy function.
927
- * @typeParam Args The arguments type of the spy function.
928
- * @typeParam Return The return type of the spy function.
929
- * @typeParam ExpectedArg The expected type of the argument for the spy to be called.
930
- * @param spy The spy to check.
931
- * @param callIndex The index of the call to check.
932
- * @param argIndex The index of the arguments to check.
933
- * @param expected The expected argument.
934
- * @returns The actual argument.
935
- */
936
- function assertSpyCallArg(spy, callIndex, argIndex, expected) {
937
- const call = getSpyCall(spy, callIndex);
938
- const arg = call === null || call === void 0 ? void 0 : call.args[argIndex];
939
- (0, equals_js_1.assertEquals)(arg, expected);
940
- return arg;
941
- }
942
- function assertSpyCallArgs(spy, callIndex, argsStart, argsEnd, expected) {
943
- const call = getSpyCall(spy, callIndex);
944
- if (!expected) {
945
- expected = argsEnd;
946
- argsEnd = undefined;
947
- }
948
- if (!expected) {
949
- expected = argsStart;
950
- argsStart = undefined;
951
- }
952
- const args = typeof argsEnd === "number"
953
- ? call.args.slice(argsStart, argsEnd)
954
- : typeof argsStart === "number"
955
- ? call.args.slice(argsStart)
956
- : call.args;
957
- (0, equals_js_1.assertEquals)(args, expected);
958
- return args;
959
- }
960
- /**
961
- * Creates a function that returns the instance the method was called on.
962
- *
963
- * @example Usage
964
- * ```ts
965
- * import { returnsThis } from "@std/testing/mock";
966
- * import { assertEquals } from "@std/assert";
967
- *
968
- * const func = returnsThis();
969
- * const obj = { func };
970
- * assertEquals(obj.func(), obj);
971
- * ```
972
- *
973
- * @typeParam Self The self type of the returned function.
974
- * @typeParam Args The arguments type of the returned function.
975
- * @returns A function that returns the instance the method was called on.
976
- */
977
- function returnsThis() {
978
- return function () {
979
- return this;
980
- };
981
- }
982
- /**
983
- * Creates a function that returns one of its arguments.
984
- *
985
- * @example Usage
986
- * ```ts
987
- * import { returnsArg } from "@std/testing/mock";
988
- * import { assertEquals } from "@std/assert";
989
- *
990
- * const func = returnsArg(1);
991
- * assertEquals(func(1, 2, 3), 2);
992
- * ```
993
- *
994
- * @typeParam Arg The type of returned argument.
995
- * @typeParam Self The self type of the returned function.
996
- * @param idx The index of the arguments to use.
997
- * @returns A function that returns one of its arguments.
998
- */
999
- function returnsArg(idx) {
1000
- return function (...args) {
1001
- return args[idx];
1002
- };
1003
- }
1004
- /**
1005
- * Creates a function that returns its arguments or a subset of them. If end is specified, it will return arguments up to but not including the end.
1006
- *
1007
- * @example Usage
1008
- * ```ts
1009
- * import { returnsArgs } from "@std/testing/mock";
1010
- * import { assertEquals } from "@std/assert";
1011
- *
1012
- * const func = returnsArgs();
1013
- * assertEquals(func(1, 2, 3), [1, 2, 3]);
1014
- * ```
1015
- *
1016
- * @typeParam Args The arguments type of the returned function
1017
- * @typeParam Self The self type of the returned function
1018
- * @param start The start index of the arguments to return. Default is 0.
1019
- * @param end The end index of the arguments to return.
1020
- * @returns A function that returns its arguments or a subset of them.
1021
- */
1022
- function returnsArgs(start = 0, end) {
1023
- return function (...args) {
1024
- return args.slice(start, end);
1025
- };
1026
- }
1027
- /**
1028
- * Creates a function that returns the iterable values. Any iterable values that are errors will be thrown.
1029
- *
1030
- * @example Usage
1031
- * ```ts
1032
- * import { returnsNext } from "@std/testing/mock";
1033
- * import { assertEquals, assertThrows } from "@std/assert";
1034
- *
1035
- * const func = returnsNext([1, 2, new Error("foo"), 3]);
1036
- * assertEquals(func(), 1);
1037
- * assertEquals(func(), 2);
1038
- * assertThrows(() => func(), Error, "foo");
1039
- * assertEquals(func(), 3);
1040
- * ```
1041
- *
1042
- * @typeParam Return The type of each item of the iterable
1043
- * @typeParam Self The self type of the returned function
1044
- * @typeParam Args The arguments type of the returned function
1045
- * @param values The iterable values
1046
- * @return A function that returns the iterable values
1047
- */
1048
- function returnsNext(values) {
1049
- const gen = (function* returnsValue() {
1050
- yield* values;
1051
- })();
1052
- let calls = 0;
1053
- return function () {
1054
- const next = gen.next();
1055
- if (next.done) {
1056
- throw new MockError(`Not expected to be called more than ${calls} time(s)`);
1057
- }
1058
- calls++;
1059
- const { value } = next;
1060
- if (value instanceof Error)
1061
- throw value;
1062
- return value;
1063
- };
1064
- }
1065
- /**
1066
- * Creates a function that resolves the awaited iterable values. Any awaited iterable values that are errors will be thrown.
1067
- *
1068
- * @example Usage
1069
- * ```ts
1070
- * import { resolvesNext } from "@std/testing/mock";
1071
- * import { assertEquals, assertRejects } from "@std/assert";
1072
- *
1073
- * const func = resolvesNext([1, 2, new Error("foo"), 3]);
1074
- * assertEquals(await func(), 1);
1075
- * assertEquals(await func(), 2);
1076
- * assertRejects(() => func(), Error, "foo");
1077
- * assertEquals(await func(), 3);
1078
- * ```
1079
- *
1080
- * @typeParam Return The type of each item of the iterable
1081
- * @typeParam Self The self type of the returned function
1082
- * @typeParam Args The type of arguments of the returned function
1083
- * @param iterable The iterable to use
1084
- * @returns A function that resolves the awaited iterable values
1085
- */
1086
- function resolvesNext(iterable) {
1087
- const gen = (async function* returnsValue() {
1088
- yield* iterable;
1089
- })();
1090
- let calls = 0;
1091
- return async function () {
1092
- const next = await gen.next();
1093
- if (next.done) {
1094
- throw new MockError(`Not expected to be called more than ${calls} time(s)`);
1095
- }
1096
- calls++;
1097
- const { value } = next;
1098
- if (value instanceof Error)
1099
- throw value;
1100
- return value;
1101
- };
1102
- }