@cparra/apexdocs 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (261) hide show
  1. package/README.md +11 -5
  2. package/package.json +4 -1
  3. package/.github/workflows/ci.yaml +0 -22
  4. package/.github/workflows/close_stale.yml +0 -22
  5. package/.prettierrc.js +0 -7
  6. package/__mocks__/chalk.js +0 -12
  7. package/__mocks__/log-update.js +0 -6
  8. package/eslint.config.mjs +0 -10
  9. package/examples/README.md +0 -5
  10. package/examples/docsify/README.md +0 -17
  11. package/examples/docsify/apexdocs.config.ts +0 -13
  12. package/examples/docsify/classes/ASampleClass.cls +0 -57
  13. package/examples/docsify/classes/CodeControl.cls +0 -19
  14. package/examples/docsify/classes/SampleClass.cls +0 -95
  15. package/examples/docsify/classes/SampleInterface.cls +0 -17
  16. package/examples/docsify/classes/SomeDto.cls +0 -122
  17. package/examples/docsify/docs/.nojekyll +0 -0
  18. package/examples/docsify/docs/README.md +0 -25
  19. package/examples/docsify/docs/_config.yml +0 -1
  20. package/examples/docsify/docs/index.html +0 -22
  21. package/examples/docsify/docs/miscellaneous/ASampleClass.md +0 -88
  22. package/examples/docsify/docs/miscellaneous/CodeControl.md +0 -107
  23. package/examples/docsify/docs/miscellaneous/SomeDto.md +0 -244
  24. package/examples/docsify/docs/sample-classes/SampleClass.md +0 -171
  25. package/examples/docsify/docs/sample-interfaces/SampleInterface.md +0 -36
  26. package/examples/docsify/package-lock.json +0 -2459
  27. package/examples/docsify/package.json +0 -14
  28. package/examples/imported/.forceignore +0 -12
  29. package/examples/imported/README.md +0 -6
  30. package/examples/imported/config/project-scratch-def.json +0 -5
  31. package/examples/imported/docs/index.md +0 -109
  32. package/examples/imported/docs/miscellaneous/BaseClass.md +0 -13
  33. package/examples/imported/docs/miscellaneous/MultiInheritanceClass.md +0 -69
  34. package/examples/imported/docs/miscellaneous/ParentInterface.md +0 -12
  35. package/examples/imported/docs/miscellaneous/ReferencedEnum.md +0 -5
  36. package/examples/imported/docs/miscellaneous/SampleException.md +0 -21
  37. package/examples/imported/docs/miscellaneous/SampleInterface.md +0 -113
  38. package/examples/imported/docs/miscellaneous/Url.md +0 -308
  39. package/examples/imported/docs/sample-enums/SampleEnum.md +0 -33
  40. package/examples/imported/docs/samplegroup/SampleClass.md +0 -167
  41. package/examples/imported/force-app/classes/BaseClass.cls +0 -3
  42. package/examples/imported/force-app/classes/MultiInheritanceClass.cls +0 -1
  43. package/examples/imported/force-app/classes/ParentInterface.cls +0 -3
  44. package/examples/imported/force-app/classes/ReferencedEnum.cls +0 -3
  45. package/examples/imported/force-app/classes/SampleClass.cls +0 -72
  46. package/examples/imported/force-app/classes/SampleEnum.cls +0 -30
  47. package/examples/imported/force-app/classes/SampleException.cls +0 -17
  48. package/examples/imported/force-app/classes/SampleInterface.cls +0 -50
  49. package/examples/imported/force-app/classes/Url.cls +0 -196
  50. package/examples/imported/package-lock.json +0 -665
  51. package/examples/imported/package.json +0 -6
  52. package/examples/imported/scripts/process-docs.mjs +0 -16
  53. package/examples/imported/sfdx-project.json +0 -12
  54. package/examples/markdown/.forceignore +0 -12
  55. package/examples/markdown/README.md +0 -7
  56. package/examples/markdown/config/project-scratch-def.json +0 -5
  57. package/examples/markdown/docs/index.md +0 -109
  58. package/examples/markdown/docs/miscellaneous/BaseClass.md +0 -16
  59. package/examples/markdown/docs/miscellaneous/MultiInheritanceClass.md +0 -72
  60. package/examples/markdown/docs/miscellaneous/ParentInterface.md +0 -15
  61. package/examples/markdown/docs/miscellaneous/ReferencedEnum.md +0 -8
  62. package/examples/markdown/docs/miscellaneous/SampleException.md +0 -24
  63. package/examples/markdown/docs/miscellaneous/SampleInterface.md +0 -116
  64. package/examples/markdown/docs/miscellaneous/Url.md +0 -311
  65. package/examples/markdown/docs/sample-enums/SampleEnum.md +0 -36
  66. package/examples/markdown/docs/samplegroup/SampleClass.md +0 -170
  67. package/examples/markdown/force-app/classes/BaseClass.cls +0 -3
  68. package/examples/markdown/force-app/classes/MultiInheritanceClass.cls +0 -1
  69. package/examples/markdown/force-app/classes/ParentInterface.cls +0 -3
  70. package/examples/markdown/force-app/classes/ReferencedEnum.cls +0 -3
  71. package/examples/markdown/force-app/classes/SampleClass.cls +0 -72
  72. package/examples/markdown/force-app/classes/SampleEnum.cls +0 -30
  73. package/examples/markdown/force-app/classes/SampleException.cls +0 -17
  74. package/examples/markdown/force-app/classes/SampleInterface.cls +0 -50
  75. package/examples/markdown/force-app/classes/Url.cls +0 -196
  76. package/examples/markdown/package-lock.json +0 -665
  77. package/examples/markdown/package.json +0 -20
  78. package/examples/markdown/sfdx-project.json +0 -12
  79. package/examples/markdown-jsconfig/.forceignore +0 -12
  80. package/examples/markdown-jsconfig/README.md +0 -9
  81. package/examples/markdown-jsconfig/apexdocs.config.mjs +0 -22
  82. package/examples/markdown-jsconfig/config/project-scratch-def.json +0 -5
  83. package/examples/markdown-jsconfig/docs/index.md +0 -12
  84. package/examples/markdown-jsconfig/docs/miscellaneous/Url.md +0 -315
  85. package/examples/markdown-jsconfig/force-app/classes/Url.cls +0 -196
  86. package/examples/markdown-jsconfig/package-lock.json +0 -665
  87. package/examples/markdown-jsconfig/package.json +0 -15
  88. package/examples/markdown-jsconfig/sfdx-project.json +0 -12
  89. package/examples/open-api/README.md +0 -5
  90. package/examples/open-api/config/project-scratch-def.json +0 -13
  91. package/examples/open-api/docs/openapi.json +0 -14
  92. package/examples/open-api/force-app/main/default/classes/ChildClass.cls +0 -42
  93. package/examples/open-api/force-app/main/default/classes/SampleClass.cls +0 -167
  94. package/examples/open-api/force-app/main/default/restapi/SampleRestResource.cls +0 -195
  95. package/examples/open-api/force-app/main/default/restapi/SampleRestResourceToSkip.cls +0 -35
  96. package/examples/open-api/force-app/main/default/restapi/SampleRestResourceWithInnerClass.cls +0 -24
  97. package/examples/open-api/force-app/main/default/restapi/SampleRestResourceWithoutApexDocs.cls +0 -15
  98. package/examples/open-api/force-app/main/default/restapi/references/Reference1.cls +0 -9
  99. package/examples/open-api/force-app/main/default/restapi/references/Reference2.cls +0 -9
  100. package/examples/open-api/force-app/main/default/restapi/references/Reference3.cls +0 -3
  101. package/examples/open-api/force-app/main/default/restapi/references/Reference4.cls +0 -3
  102. package/examples/open-api/force-app/main/default/restapi/references/Reference5.cls +0 -3
  103. package/examples/open-api/force-app/main/default/restapi/references/Reference6.cls +0 -6
  104. package/examples/open-api/force-app/main/default/restapi/references/Reference7.cls +0 -3
  105. package/examples/open-api/package-lock.json +0 -724
  106. package/examples/open-api/package.json +0 -20
  107. package/examples/open-api/sfdx-project.json +0 -12
  108. package/examples/vitepress/.forceignore +0 -12
  109. package/examples/vitepress/README.md +0 -25
  110. package/examples/vitepress/apexdocs.config.ts +0 -113
  111. package/examples/vitepress/config/project-scratch-def.json +0 -13
  112. package/examples/vitepress/docs/.vitepress/cache/deps/@theme_index.js +0 -259
  113. package/examples/vitepress/docs/.vitepress/cache/deps/@theme_index.js.map +0 -7
  114. package/examples/vitepress/docs/.vitepress/cache/deps/_metadata.json +0 -40
  115. package/examples/vitepress/docs/.vitepress/cache/deps/chunk-574YRH25.js +0 -11474
  116. package/examples/vitepress/docs/.vitepress/cache/deps/chunk-574YRH25.js.map +0 -7
  117. package/examples/vitepress/docs/.vitepress/cache/deps/chunk-E5DZZB2I.js +0 -9172
  118. package/examples/vitepress/docs/.vitepress/cache/deps/chunk-E5DZZB2I.js.map +0 -7
  119. package/examples/vitepress/docs/.vitepress/cache/deps/package.json +0 -3
  120. package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +0 -4339
  121. package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +0 -7
  122. package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +0 -567
  123. package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +0 -7
  124. package/examples/vitepress/docs/.vitepress/cache/deps/vue.js +0 -323
  125. package/examples/vitepress/docs/.vitepress/cache/deps/vue.js.map +0 -7
  126. package/examples/vitepress/docs/.vitepress/config.mts +0 -21
  127. package/examples/vitepress/docs/.vitepress/sidebar.json +0 -119
  128. package/examples/vitepress/docs/api-examples.md +0 -49
  129. package/examples/vitepress/docs/index-frontmatter.md +0 -16
  130. package/examples/vitepress/docs/index.md +0 -56
  131. package/examples/vitepress/docs/markdown-examples.md +0 -85
  132. package/examples/vitepress/docs/miscellaneous/BaseClass.md +0 -20
  133. package/examples/vitepress/docs/miscellaneous/MultiInheritanceClass.md +0 -76
  134. package/examples/vitepress/docs/miscellaneous/ParentInterface.md +0 -19
  135. package/examples/vitepress/docs/miscellaneous/ReferencedEnum.md +0 -15
  136. package/examples/vitepress/docs/miscellaneous/SampleException.md +0 -28
  137. package/examples/vitepress/docs/miscellaneous/SampleInterface.md +0 -116
  138. package/examples/vitepress/docs/miscellaneous/Url.md +0 -317
  139. package/examples/vitepress/docs/sample-enums/SampleEnum.md +0 -40
  140. package/examples/vitepress/docs/samplegroup/SampleClass.md +0 -174
  141. package/examples/vitepress/force-app/main/default/classes/BaseClass.cls +0 -3
  142. package/examples/vitepress/force-app/main/default/classes/MultiInheritanceClass.cls +0 -1
  143. package/examples/vitepress/force-app/main/default/classes/ParentInterface.cls +0 -3
  144. package/examples/vitepress/force-app/main/default/classes/ReferencedEnum.cls +0 -5
  145. package/examples/vitepress/force-app/main/default/classes/Url.cls +0 -198
  146. package/examples/vitepress/force-app/main/default/classes/feature-a/SampleClass.cls +0 -73
  147. package/examples/vitepress/force-app/main/default/classes/feature-a/SampleEnum.cls +0 -30
  148. package/examples/vitepress/force-app/main/default/classes/feature-a/SampleException.cls +0 -17
  149. package/examples/vitepress/force-app/main/default/classes/feature-a/SampleInterface.cls +0 -46
  150. package/examples/vitepress/package-lock.json +0 -2574
  151. package/examples/vitepress/package.json +0 -18
  152. package/examples/vitepress/sfdx-project.json +0 -12
  153. package/jest.config.js +0 -10
  154. package/jest.d.ts +0 -7
  155. package/src/application/Apexdocs.ts +0 -69
  156. package/src/application/__tests__/apex-file-reader.spec.ts +0 -128
  157. package/src/application/apex-file-reader.ts +0 -56
  158. package/src/application/file-system.ts +0 -69
  159. package/src/application/file-writer.ts +0 -43
  160. package/src/application/generators/markdown.ts +0 -45
  161. package/src/application/generators/openapi.ts +0 -75
  162. package/src/cli/args.ts +0 -55
  163. package/src/cli/commands/markdown.ts +0 -56
  164. package/src/cli/commands/openapi.ts +0 -36
  165. package/src/cli/generate.ts +0 -32
  166. package/src/core/__test__/manifest.spec.ts +0 -16
  167. package/src/core/manifest.ts +0 -90
  168. package/src/core/markdown/__test__/expect-extensions.ts +0 -32
  169. package/src/core/markdown/__test__/generating-class-docs.spec.ts +0 -362
  170. package/src/core/markdown/__test__/generating-docs.spec.ts +0 -378
  171. package/src/core/markdown/__test__/generating-enum-docs.spec.ts +0 -61
  172. package/src/core/markdown/__test__/generating-interface-docs.spec.ts +0 -169
  173. package/src/core/markdown/__test__/generating-reference-guide.spec.ts +0 -196
  174. package/src/core/markdown/__test__/inheritance-chain.test.ts +0 -54
  175. package/src/core/markdown/__test__/test-helpers.ts +0 -25
  176. package/src/core/markdown/adapters/__tests__/documentables.spec.ts +0 -109
  177. package/src/core/markdown/adapters/__tests__/interface-adapter.spec.ts +0 -150
  178. package/src/core/markdown/adapters/__tests__/link-generator.spec.ts +0 -130
  179. package/src/core/markdown/adapters/__tests__/references.spec.ts +0 -136
  180. package/src/core/markdown/adapters/apex-types.ts +0 -238
  181. package/src/core/markdown/adapters/documentables.ts +0 -115
  182. package/src/core/markdown/adapters/fields-and-properties.ts +0 -45
  183. package/src/core/markdown/adapters/generate-link.ts +0 -82
  184. package/src/core/markdown/adapters/inline.ts +0 -143
  185. package/src/core/markdown/adapters/methods-and-constructors.ts +0 -133
  186. package/src/core/markdown/adapters/reference-guide.ts +0 -37
  187. package/src/core/markdown/adapters/renderable-bundle.ts +0 -61
  188. package/src/core/markdown/adapters/renderable-to-page-data.ts +0 -91
  189. package/src/core/markdown/adapters/type-utils.ts +0 -13
  190. package/src/core/markdown/adapters/types.d.ts +0 -180
  191. package/src/core/markdown/generate-docs.ts +0 -210
  192. package/src/core/markdown/reflection/__test__/filter-scope.spec.ts +0 -290
  193. package/src/core/markdown/reflection/__test__/helpers.ts +0 -18
  194. package/src/core/markdown/reflection/__test__/remove-excluded-tags.spec.ts +0 -200
  195. package/src/core/markdown/reflection/filter-scope.ts +0 -13
  196. package/src/core/markdown/reflection/inheritance-chain-expanion.ts +0 -22
  197. package/src/core/markdown/reflection/inheritance-chain.ts +0 -23
  198. package/src/core/markdown/reflection/inherited-member-expansion.ts +0 -105
  199. package/src/core/markdown/reflection/reflect-source.ts +0 -123
  200. package/src/core/markdown/reflection/remove-excluded-tags.ts +0 -168
  201. package/src/core/markdown/reflection/sort-types-and-members.ts +0 -61
  202. package/src/core/markdown/templates/class-template.ts +0 -75
  203. package/src/core/markdown/templates/constructors-partial-template.ts +0 -32
  204. package/src/core/markdown/templates/documentable-partial-template.ts +0 -26
  205. package/src/core/markdown/templates/enum-template.ts +0 -12
  206. package/src/core/markdown/templates/fieldsPartialTemplate.ts +0 -23
  207. package/src/core/markdown/templates/grouped-members-partial-template.ts +0 -6
  208. package/src/core/markdown/templates/hookable.ts +0 -7
  209. package/src/core/markdown/templates/interface-template.ts +0 -16
  210. package/src/core/markdown/templates/methods-partial-template.ts +0 -43
  211. package/src/core/markdown/templates/reference-guide.ts +0 -14
  212. package/src/core/markdown/templates/template.ts +0 -114
  213. package/src/core/markdown/templates/type-doc-partial.ts +0 -27
  214. package/src/core/markdown/utils.ts +0 -3
  215. package/src/core/openApiSettings.ts +0 -41
  216. package/src/core/openapi/__tests__/manifest-factory.spec.ts +0 -16
  217. package/src/core/openapi/__tests__/open-api-docs-processor.spec.ts +0 -59
  218. package/src/core/openapi/__tests__/open-api.spec.ts +0 -22
  219. package/src/core/openapi/apex-doc-types.ts +0 -26
  220. package/src/core/openapi/apex-type-wrappers/ClassMirrorWrapper.ts +0 -12
  221. package/src/core/openapi/apex-type-wrappers/MethodMirrorWrapper.ts +0 -11
  222. package/src/core/openapi/apex-type-wrappers/__tests__/ClassMirrorWrapper.spec.ts +0 -15
  223. package/src/core/openapi/file-container.ts +0 -13
  224. package/src/core/openapi/manifest-factory.ts +0 -16
  225. package/src/core/openapi/open-api-docs-processor.ts +0 -93
  226. package/src/core/openapi/open-api-types.ts +0 -119
  227. package/src/core/openapi/open-api.ts +0 -45
  228. package/src/core/openapi/openapi-type-file.ts +0 -12
  229. package/src/core/openapi/parser.ts +0 -163
  230. package/src/core/openapi/parsers/Builder.ts +0 -40
  231. package/src/core/openapi/parsers/MethodParser.ts +0 -249
  232. package/src/core/openapi/parsers/ParameterObjectBuilder.ts +0 -13
  233. package/src/core/openapi/parsers/ReferenceBuilder.ts +0 -299
  234. package/src/core/openapi/parsers/RequestBodyBuilder.ts +0 -19
  235. package/src/core/openapi/parsers/ResponsesBuilder.ts +0 -21
  236. package/src/core/openapi/parsers/__tests__/MethodParser.spec.ts +0 -44
  237. package/src/core/openapi/parsers/__tests__/ParameterObjectBuilder.spec.ts +0 -68
  238. package/src/core/openapi/parsers/__tests__/ReferenceBuilder.spec.ts +0 -751
  239. package/src/core/openapi/parsers/__tests__/RequestBodyBuilder.spec.ts +0 -64
  240. package/src/core/openapi/parsers/__tests__/ResponsesBuilder.spec.ts +0 -55
  241. package/src/core/openapi/transpiler.ts +0 -17
  242. package/src/core/openapi/types-repository.ts +0 -54
  243. package/src/core/parse-apex-metadata.ts +0 -30
  244. package/src/core/shared/types.d.ts +0 -150
  245. package/src/core/shared/utils.ts +0 -5
  246. package/src/defaults.ts +0 -21
  247. package/src/index.ts +0 -110
  248. package/src/test-helpers/AnnotationBuilder.ts +0 -29
  249. package/src/test-helpers/ClassMirrorBuilder.ts +0 -69
  250. package/src/test-helpers/DocCommentAnnotationBuilder.ts +0 -24
  251. package/src/test-helpers/DocCommentBuilder.ts +0 -36
  252. package/src/test-helpers/FieldMirrorBuilder.ts +0 -59
  253. package/src/test-helpers/InterfaceMirrorBuilder.ts +0 -39
  254. package/src/test-helpers/MethodMirrorBuilder.ts +0 -77
  255. package/src/test-helpers/SettingsBuilder.ts +0 -17
  256. package/src/util/error-logger.ts +0 -92
  257. package/src/util/fp.ts +0 -3
  258. package/src/util/logger.ts +0 -51
  259. package/src/util/string-utils.ts +0 -7
  260. package/tsconfig.json +0 -25
  261. package/tslint.json +0 -6
@@ -1,751 +0,0 @@
1
- import { TypesRepository } from '../../../../core/openapi/types-repository';
2
- import { ReferenceBuilder } from '../ReferenceBuilder';
3
- import { ClassMirrorBuilder } from '../../../../test-helpers/ClassMirrorBuilder';
4
- import { FieldMirrorBuilder } from '../../../../test-helpers/FieldMirrorBuilder';
5
- import { SchemaObjectArray, SchemaObjectObject } from '../../../../core/openapi/open-api-types';
6
- import { DocCommentBuilder } from '../../../../test-helpers/DocCommentBuilder';
7
- import { DocCommentAnnotationBuilder } from '../../../../test-helpers/DocCommentAnnotationBuilder';
8
-
9
- describe('ReferenceBuilder', () => {
10
- describe('Validation', () => {
11
- it('should throw an error if the reference does not exist', function () {
12
- TypesRepository.getInstance = jest.fn().mockReturnValue({
13
- getFromAllByName: jest.fn().mockReturnValue(undefined),
14
- });
15
-
16
- expect(() => {
17
- new ReferenceBuilder().build('AnyName');
18
- }).toThrow(Error);
19
- });
20
- });
21
-
22
- describe('Filters out members', () => {
23
- it('should filter out static members', function () {
24
- const classMirror = new ClassMirrorBuilder()
25
- .withName('className')
26
- .addFiled(new FieldMirrorBuilder().addMemberModifier('static').build())
27
- .build();
28
-
29
- TypesRepository.getInstance = jest.fn().mockReturnValue({
30
- getFromAllByName: jest.fn().mockReturnValue({ type: classMirror, isChild: false }),
31
- });
32
-
33
- const result = new ReferenceBuilder().build('className');
34
-
35
- expect(result.referenceComponents).toHaveLength(1);
36
- expect(result.referenceComponents[0].referencedClass).toBe('className');
37
- expect(result.entrypointReferenceObject.$ref).toBe('#/components/schemas/className');
38
- expect((result.referenceComponents[0].schema as SchemaObjectObject).type).toBe('object');
39
- expect((result.referenceComponents[0].schema as SchemaObjectObject).properties).toMatchObject({});
40
- });
41
-
42
- it('should filter out transient members', function () {
43
- const classMirror = new ClassMirrorBuilder()
44
- .withName('className')
45
- .addFiled(new FieldMirrorBuilder().addMemberModifier('transient').build())
46
- .build();
47
-
48
- TypesRepository.getInstance = jest.fn().mockReturnValue({
49
- getFromAllByName: jest.fn().mockReturnValue({ type: classMirror, isChild: false }),
50
- });
51
-
52
- const result = new ReferenceBuilder().build('className');
53
-
54
- expect(result.referenceComponents).toHaveLength(1);
55
- expect(result.referenceComponents[0].referencedClass).toBe('className');
56
- expect(result.entrypointReferenceObject.$ref).toBe('#/components/schemas/className');
57
- expect((result.referenceComponents[0].schema as SchemaObjectObject).type).toBe('object');
58
- expect((result.referenceComponents[0].schema as SchemaObjectObject).properties).toMatchObject({});
59
- });
60
-
61
- it('should include private members', function () {
62
- const classMirror = new ClassMirrorBuilder()
63
- .withName('className')
64
- .addFiled(new FieldMirrorBuilder().withName('fieldName').withAccessModifier('private').build())
65
- .build();
66
-
67
- TypesRepository.getInstance = jest.fn().mockReturnValue({
68
- getFromAllByName: jest.fn().mockReturnValue({ type: classMirror, isChild: false }),
69
- });
70
-
71
- const result = new ReferenceBuilder().build('className');
72
-
73
- expect(result.referenceComponents).toHaveLength(1);
74
- expect(result.referenceComponents[0].referencedClass).toBe('className');
75
- expect(result.entrypointReferenceObject.$ref).toBe('#/components/schemas/className');
76
- expect((result.referenceComponents[0].schema as SchemaObjectObject).type).toBe('object');
77
- expect((result.referenceComponents[0].schema as SchemaObjectObject).properties).toHaveProperty('fieldName');
78
- });
79
-
80
- it('should include protected members', function () {
81
- const classMirror = new ClassMirrorBuilder()
82
- .withName('className')
83
- .addFiled(new FieldMirrorBuilder().withName('fieldName').withAccessModifier('protected').build())
84
- .build();
85
-
86
- TypesRepository.getInstance = jest.fn().mockReturnValue({
87
- getFromAllByName: jest.fn().mockReturnValue({ type: classMirror, isChild: false }),
88
- });
89
-
90
- const result = new ReferenceBuilder().build('className');
91
-
92
- expect(result.referenceComponents).toHaveLength(1);
93
- expect(result.referenceComponents[0].referencedClass).toBe('className');
94
- expect(result.entrypointReferenceObject.$ref).toBe('#/components/schemas/className');
95
- expect((result.referenceComponents[0].schema as SchemaObjectObject).type).toBe('object');
96
- expect((result.referenceComponents[0].schema as SchemaObjectObject).properties).toHaveProperty('fieldName');
97
- });
98
-
99
- it('should include public members', function () {
100
- const classMirror = new ClassMirrorBuilder()
101
- .withName('className')
102
- .addFiled(new FieldMirrorBuilder().withName('fieldName').withAccessModifier('public').build())
103
- .build();
104
-
105
- TypesRepository.getInstance = jest.fn().mockReturnValue({
106
- getFromAllByName: jest.fn().mockReturnValue({ type: classMirror, isChild: false }),
107
- });
108
-
109
- const result = new ReferenceBuilder().build('className');
110
-
111
- expect(result.referenceComponents).toHaveLength(1);
112
- expect(result.referenceComponents[0].referencedClass).toBe('className');
113
- expect(result.entrypointReferenceObject.$ref).toBe('#/components/schemas/className');
114
- expect((result.referenceComponents[0].schema as SchemaObjectObject).type).toBe('object');
115
- expect((result.referenceComponents[0].schema as SchemaObjectObject).properties).toHaveProperty('fieldName');
116
- });
117
-
118
- it('should include global members', function () {
119
- const classMirror = new ClassMirrorBuilder()
120
- .withName('className')
121
- .addFiled(new FieldMirrorBuilder().withName('fieldName').withAccessModifier('global').build())
122
- .build();
123
-
124
- TypesRepository.getInstance = jest.fn().mockReturnValue({
125
- getFromAllByName: jest.fn().mockReturnValue({ type: classMirror, isChild: false }),
126
- });
127
-
128
- const result = new ReferenceBuilder().build('className');
129
-
130
- expect(result.referenceComponents).toHaveLength(1);
131
- expect(result.referenceComponents[0].referencedClass).toBe('className');
132
- expect(result.entrypointReferenceObject.$ref).toBe('#/components/schemas/className');
133
- expect((result.referenceComponents[0].schema as SchemaObjectObject).type).toBe('object');
134
- expect((result.referenceComponents[0].schema as SchemaObjectObject).properties).toHaveProperty('fieldName');
135
- });
136
- });
137
-
138
- describe('Primitive Apex types are supported', () => {
139
- it('should correctly identify and parse Boolean fields', function () {
140
- const classMirror = new ClassMirrorBuilder()
141
- .addFiled(new FieldMirrorBuilder().withName('fieldName').withType('Boolean').build())
142
- .build();
143
-
144
- TypesRepository.getInstance = jest.fn().mockReturnValue({
145
- getFromAllByName: jest.fn().mockReturnValue({ type: classMirror, isChild: false }),
146
- });
147
-
148
- const result = new ReferenceBuilder().build('className');
149
-
150
- const schema = result.referenceComponents[0].schema as SchemaObjectObject;
151
- expect(schema.properties).toHaveProperty('fieldName');
152
- const fieldSchema = schema.properties!['fieldName'] as SchemaObjectObject;
153
- expect(fieldSchema.type).toBe('boolean');
154
- });
155
-
156
- it('should correctly identify and parse Date fields', function () {
157
- const classMirror = new ClassMirrorBuilder()
158
- .addFiled(new FieldMirrorBuilder().withName('fieldName').withType('Date').build())
159
- .build();
160
-
161
- TypesRepository.getInstance = jest.fn().mockReturnValue({
162
- getFromAllByName: jest.fn().mockReturnValue({ type: classMirror, isChild: false }),
163
- });
164
-
165
- const result = new ReferenceBuilder().build('className');
166
-
167
- const schema = result.referenceComponents[0].schema as SchemaObjectObject;
168
- expect(schema.properties).toHaveProperty('fieldName');
169
- const fieldSchema = schema.properties!['fieldName'] as SchemaObjectObject;
170
- expect(fieldSchema.type).toBe('string');
171
- expect(fieldSchema.format).toBe('date');
172
- });
173
-
174
- it('should correctly identify and parse Datetime fields', function () {
175
- const classMirror = new ClassMirrorBuilder()
176
- .addFiled(new FieldMirrorBuilder().withName('fieldName').withType('Datetime').build())
177
- .build();
178
-
179
- TypesRepository.getInstance = jest.fn().mockReturnValue({
180
- getFromAllByName: jest.fn().mockReturnValue({ type: classMirror, isChild: false }),
181
- });
182
-
183
- const result = new ReferenceBuilder().build('className');
184
-
185
- const schema = result.referenceComponents[0].schema as SchemaObjectObject;
186
- expect(schema.properties).toHaveProperty('fieldName');
187
- const fieldSchema = schema.properties!['fieldName'] as SchemaObjectObject;
188
- expect(fieldSchema.type).toBe('string');
189
- expect(fieldSchema.format).toBe('date-time');
190
- });
191
-
192
- it('should correctly identify and parse Decimal fields', function () {
193
- const classMirror = new ClassMirrorBuilder()
194
- .addFiled(new FieldMirrorBuilder().withName('fieldName').withType('Decimal').build())
195
- .build();
196
-
197
- TypesRepository.getInstance = jest.fn().mockReturnValue({
198
- getFromAllByName: jest.fn().mockReturnValue({ type: classMirror, isChild: false }),
199
- });
200
-
201
- const result = new ReferenceBuilder().build('className');
202
-
203
- const schema = result.referenceComponents[0].schema as SchemaObjectObject;
204
- expect(schema.properties).toHaveProperty('fieldName');
205
- const fieldSchema = schema.properties!['fieldName'] as SchemaObjectObject;
206
- expect(fieldSchema.type).toBe('number');
207
- });
208
-
209
- it('should correctly identify and parse Double fields', function () {
210
- const classMirror = new ClassMirrorBuilder()
211
- .addFiled(new FieldMirrorBuilder().withName('fieldName').withType('Double').build())
212
- .build();
213
-
214
- TypesRepository.getInstance = jest.fn().mockReturnValue({
215
- getFromAllByName: jest.fn().mockReturnValue({ type: classMirror, isChild: false }),
216
- });
217
-
218
- const result = new ReferenceBuilder().build('className');
219
-
220
- const schema = result.referenceComponents[0].schema as SchemaObjectObject;
221
- expect(schema.properties).toHaveProperty('fieldName');
222
- const fieldSchema = schema.properties!['fieldName'] as SchemaObjectObject;
223
- expect(fieldSchema.type).toBe('number');
224
- });
225
-
226
- it('should correctly identify and parse ID fields', function () {
227
- const classMirror = new ClassMirrorBuilder()
228
- .addFiled(new FieldMirrorBuilder().withName('fieldName').withType('ID').build())
229
- .build();
230
-
231
- TypesRepository.getInstance = jest.fn().mockReturnValue({
232
- getFromAllByName: jest.fn().mockReturnValue({ type: classMirror, isChild: false }),
233
- });
234
-
235
- const result = new ReferenceBuilder().build('className');
236
-
237
- const schema = result.referenceComponents[0].schema as SchemaObjectObject;
238
- expect(schema.properties).toHaveProperty('fieldName');
239
- const fieldSchema = schema.properties!['fieldName'] as SchemaObjectObject;
240
- expect(fieldSchema.type).toBe('string');
241
- });
242
-
243
- it('should correctly identify and parse Integer fields', function () {
244
- const classMirror = new ClassMirrorBuilder()
245
- .addFiled(new FieldMirrorBuilder().withName('fieldName').withType('Integer').build())
246
- .build();
247
-
248
- TypesRepository.getInstance = jest.fn().mockReturnValue({
249
- getFromAllByName: jest.fn().mockReturnValue({ type: classMirror, isChild: false }),
250
- });
251
-
252
- const result = new ReferenceBuilder().build('className');
253
-
254
- const schema = result.referenceComponents[0].schema as SchemaObjectObject;
255
- expect(schema.properties).toHaveProperty('fieldName');
256
- const fieldSchema = schema.properties!['fieldName'] as SchemaObjectObject;
257
- expect(fieldSchema.type).toBe('integer');
258
- });
259
-
260
- it('should correctly identify and parse Long fields', function () {
261
- const classMirror = new ClassMirrorBuilder()
262
- .addFiled(new FieldMirrorBuilder().withName('fieldName').withType('Long').build())
263
- .build();
264
-
265
- TypesRepository.getInstance = jest.fn().mockReturnValue({
266
- getFromAllByName: jest.fn().mockReturnValue({ type: classMirror, isChild: false }),
267
- });
268
-
269
- const result = new ReferenceBuilder().build('className');
270
-
271
- const schema = result.referenceComponents[0].schema as SchemaObjectObject;
272
- expect(schema.properties).toHaveProperty('fieldName');
273
- const fieldSchema = schema.properties!['fieldName'] as SchemaObjectObject;
274
- expect(fieldSchema.type).toBe('integer');
275
- expect(fieldSchema.format).toBe('int64');
276
- });
277
-
278
- it('should correctly identify and parse String fields', function () {
279
- const classMirror = new ClassMirrorBuilder()
280
- .addFiled(new FieldMirrorBuilder().withName('fieldName').withType('String').build())
281
- .build();
282
-
283
- TypesRepository.getInstance = jest.fn().mockReturnValue({
284
- getFromAllByName: jest.fn().mockReturnValue({ type: classMirror, isChild: false }),
285
- });
286
-
287
- const result = new ReferenceBuilder().build('className');
288
-
289
- const schema = result.referenceComponents[0].schema as SchemaObjectObject;
290
- expect(schema.properties).toHaveProperty('fieldName');
291
- const fieldSchema = schema.properties!['fieldName'] as SchemaObjectObject;
292
- expect(fieldSchema.type).toBe('string');
293
- });
294
-
295
- it('should correctly identify and parse Time fields', function () {
296
- const classMirror = new ClassMirrorBuilder()
297
- .addFiled(new FieldMirrorBuilder().withName('fieldName').withType('Time').build())
298
- .build();
299
-
300
- TypesRepository.getInstance = jest.fn().mockReturnValue({
301
- getFromAllByName: jest.fn().mockReturnValue({ type: classMirror, isChild: false }),
302
- });
303
-
304
- const result = new ReferenceBuilder().build('className');
305
-
306
- const schema = result.referenceComponents[0].schema as SchemaObjectObject;
307
- expect(schema.properties).toHaveProperty('fieldName');
308
- const fieldSchema = schema.properties!['fieldName'] as SchemaObjectObject;
309
- expect(fieldSchema.type).toBe('string');
310
- expect(fieldSchema.format).toBe('time');
311
- });
312
- });
313
-
314
- describe('Collection of primitives are supported', () => {
315
- it('should correctly identify and parse a list of primitive fields', function () {
316
- const classMirror = new ClassMirrorBuilder()
317
- .addFiled(
318
- new FieldMirrorBuilder()
319
- .withName('fieldName')
320
- .withReferencedType({
321
- type: 'List',
322
- rawDeclaration: 'List<Boolean>',
323
- ofType: {
324
- type: 'Boolean',
325
- rawDeclaration: 'Boolean',
326
- },
327
- })
328
- .build(),
329
- )
330
- .build();
331
-
332
- TypesRepository.getInstance = jest.fn().mockReturnValue({
333
- getFromAllByName: jest.fn().mockReturnValue({ type: classMirror, isChild: false }),
334
- });
335
-
336
- const result = new ReferenceBuilder().build('className');
337
-
338
- const schema = result.referenceComponents[0].schema as SchemaObjectObject;
339
- expect(schema.properties).toHaveProperty('fieldName');
340
-
341
- const fieldSchema = schema.properties!['fieldName'] as SchemaObjectArray;
342
- expect(fieldSchema.type).toBe('array');
343
-
344
- const collectionOf = fieldSchema.items as SchemaObjectObject;
345
- expect(collectionOf.type).toBe('boolean');
346
- });
347
-
348
- it('should correctly identify and parse a set of primitive fields', function () {
349
- const classMirror = new ClassMirrorBuilder()
350
- .addFiled(
351
- new FieldMirrorBuilder()
352
- .withName('fieldName')
353
- .withReferencedType({
354
- type: 'Set',
355
- rawDeclaration: 'List<String>',
356
- ofType: {
357
- type: 'String',
358
- rawDeclaration: 'String',
359
- },
360
- })
361
- .build(),
362
- )
363
- .build();
364
-
365
- TypesRepository.getInstance = jest.fn().mockReturnValue({
366
- getFromAllByName: jest.fn().mockReturnValue({ type: classMirror, isChild: false }),
367
- });
368
-
369
- const result = new ReferenceBuilder().build('className');
370
-
371
- const schema = result.referenceComponents[0].schema as SchemaObjectObject;
372
- expect(schema.properties).toHaveProperty('fieldName');
373
-
374
- const fieldSchema = schema.properties!['fieldName'] as SchemaObjectArray;
375
- expect(fieldSchema.type).toBe('array');
376
-
377
- const collectionOf = fieldSchema.items as SchemaObjectObject;
378
- expect(collectionOf.type).toBe('string');
379
- });
380
-
381
- it('should correctly identify and parse a map of primitive fields', function () {
382
- const classMirror = new ClassMirrorBuilder()
383
- .addFiled(
384
- new FieldMirrorBuilder()
385
- .withName('fieldName')
386
- .withReferencedType({
387
- type: 'Map',
388
- rawDeclaration: 'Map<String, Boolean>',
389
- keyType: {
390
- type: 'String',
391
- rawDeclaration: 'String',
392
- },
393
- valueType: {
394
- type: 'Boolean',
395
- rawDeclaration: 'Boolean',
396
- },
397
- })
398
- .build(),
399
- )
400
- .build();
401
-
402
- TypesRepository.getInstance = jest.fn().mockReturnValue({
403
- getFromAllByName: jest.fn().mockReturnValue({ type: classMirror, isChild: false }),
404
- });
405
-
406
- const result = new ReferenceBuilder().build('className');
407
-
408
- const schema = result.referenceComponents[0].schema as SchemaObjectObject;
409
- expect(schema.properties).toHaveProperty('fieldName');
410
-
411
- const fieldSchema = schema.properties!['fieldName'] as SchemaObjectObject;
412
- expect(fieldSchema.type).toBe('object');
413
- });
414
- });
415
-
416
- describe('References to other references', () => {
417
- it('should parse references to another reference', function () {
418
- const mainClassMirror = new ClassMirrorBuilder()
419
- .withName('parent')
420
- .addFiled(
421
- new FieldMirrorBuilder()
422
- .withName('childClassMember')
423
- .withReferencedType({
424
- type: 'ChildClass',
425
- rawDeclaration: 'ChildClass',
426
- })
427
- .build(),
428
- )
429
- .build();
430
-
431
- const childClass = new ClassMirrorBuilder()
432
- .withName('child')
433
- .addFiled(new FieldMirrorBuilder().withName('stringMember').withType('String').build())
434
- .build();
435
-
436
- TypesRepository.getInstance = jest.fn().mockReturnValue({
437
- getFromAllByName: jest
438
- .fn()
439
- .mockReturnValueOnce({ type: mainClassMirror, isChild: false })
440
- .mockReturnValueOnce({ type: childClass, isChild: false }),
441
- });
442
-
443
- const result = new ReferenceBuilder().build('className');
444
-
445
- expect(result.referenceComponents).toHaveLength(2);
446
- expect(result.referenceComponents.some((ref) => ref.referencedClass === 'parent')).toBe(true);
447
- expect(result.referenceComponents.some((ref) => ref.referencedClass === 'child')).toBe(true);
448
- });
449
-
450
- it('should parse references to multiple other references', function () {
451
- const mainClassMirror = new ClassMirrorBuilder()
452
- .withName('parent')
453
- .addFiled(
454
- new FieldMirrorBuilder()
455
- .withName('childClassMember')
456
- .withReferencedType({
457
- type: 'ChildClass',
458
- rawDeclaration: 'ChildClass',
459
- })
460
- .build(),
461
- )
462
- .addFiled(
463
- new FieldMirrorBuilder()
464
- .withName('anotherChildClassMember')
465
- .withReferencedType({
466
- type: 'AnotherChildClass',
467
- rawDeclaration: 'AnotherChildClass',
468
- })
469
- .build(),
470
- )
471
- .build();
472
-
473
- const oneChild = new ClassMirrorBuilder()
474
- .withName('onechild')
475
- .addFiled(new FieldMirrorBuilder().withName('stringMember').withType('String').build())
476
- .build();
477
-
478
- const anotherChild = new ClassMirrorBuilder()
479
- .withName('anotherchild')
480
- .addFiled(new FieldMirrorBuilder().withName('stringMember').withType('String').build())
481
- .build();
482
-
483
- TypesRepository.getInstance = jest.fn().mockReturnValue({
484
- getFromAllByName: jest
485
- .fn()
486
- .mockReturnValueOnce({ type: mainClassMirror, isChild: false })
487
- .mockReturnValueOnce({ type: oneChild, isChild: false })
488
- .mockReturnValueOnce({ type: anotherChild, isChild: false }),
489
- });
490
-
491
- const result = new ReferenceBuilder().build('className');
492
-
493
- expect(result.referenceComponents).toHaveLength(3);
494
- expect(result.referenceComponents.some((ref) => ref.referencedClass === 'parent')).toBe(true);
495
- expect(result.referenceComponents.some((ref) => ref.referencedClass === 'onechild')).toBe(true);
496
- expect(result.referenceComponents.some((ref) => ref.referencedClass === 'anotherchild')).toBe(true);
497
- });
498
-
499
- it('should parse references to collections of other references', function () {
500
- const mainClassMirror = new ClassMirrorBuilder()
501
- .withName('parent')
502
- .addFiled(
503
- new FieldMirrorBuilder()
504
- .withName('collectionOfChildren')
505
- .withReferencedType({
506
- type: 'Set',
507
- rawDeclaration: 'List<ChildClass>',
508
- ofType: {
509
- type: 'ChildClass',
510
- rawDeclaration: 'List<ChildClass>',
511
- },
512
- })
513
- .build(),
514
- )
515
- .build();
516
-
517
- const childClass = new ClassMirrorBuilder()
518
- .withName('childclass')
519
- .addFiled(new FieldMirrorBuilder().withName('stringMember').withType('String').build())
520
- .build();
521
-
522
- TypesRepository.getInstance = jest.fn().mockReturnValue({
523
- getFromAllByName: jest
524
- .fn()
525
- .mockReturnValueOnce({ type: mainClassMirror, isChild: false })
526
- .mockReturnValueOnce({ type: childClass, isChild: false }),
527
- });
528
-
529
- const result = new ReferenceBuilder().build('className');
530
-
531
- expect(result.referenceComponents).toHaveLength(2);
532
- expect(result.referenceComponents.some((ref) => ref.referencedClass === 'parent')).toBe(true);
533
- expect(result.referenceComponents.some((ref) => ref.referencedClass === 'childclass')).toBe(true);
534
- });
535
-
536
- it('should parse multiple levels of references', function () {
537
- const mainClassMirror = new ClassMirrorBuilder()
538
- .withName('parent')
539
- .addFiled(
540
- new FieldMirrorBuilder()
541
- .withName('childClassMember')
542
- .withReferencedType({
543
- type: 'ChildClass',
544
- rawDeclaration: 'ChildClass',
545
- })
546
- .build(),
547
- )
548
- .build();
549
-
550
- const childClass = new ClassMirrorBuilder()
551
- .withName('child')
552
- .addFiled(
553
- new FieldMirrorBuilder()
554
- .withName('grandChildClassMember')
555
- .withReferencedType({
556
- type: 'GrandChildClass',
557
- rawDeclaration: 'GrandChildClass',
558
- })
559
- .build(),
560
- )
561
- .build();
562
-
563
- const grandChildClass = new ClassMirrorBuilder()
564
- .withName('grandchild')
565
- .addFiled(new FieldMirrorBuilder().withName('stringMember').withType('String').build())
566
- .build();
567
-
568
- TypesRepository.getInstance = jest.fn().mockReturnValue({
569
- getFromAllByName: jest
570
- .fn()
571
- .mockReturnValueOnce({ type: mainClassMirror, isChild: false })
572
- .mockReturnValueOnce({ type: childClass, isChild: false })
573
- .mockReturnValueOnce({ type: grandChildClass, isChild: false }),
574
- });
575
-
576
- const result = new ReferenceBuilder().build('className');
577
-
578
- expect(result.referenceComponents).toHaveLength(3);
579
- expect(result.referenceComponents.some((ref) => ref.referencedClass === 'parent')).toBe(true);
580
- expect(result.referenceComponents.some((ref) => ref.referencedClass === 'child')).toBe(true);
581
- expect(result.referenceComponents.some((ref) => ref.referencedClass === 'grandchild')).toBe(true);
582
- });
583
- });
584
-
585
- describe('References to collections', () => {
586
- it('should resolve references to lists', function () {
587
- const classMirror = new ClassMirrorBuilder()
588
- .withName('classname')
589
- .addFiled(new FieldMirrorBuilder().withName('fieldName').withAccessModifier('public').build())
590
- .build();
591
-
592
- TypesRepository.getInstance = jest.fn().mockReturnValue({
593
- getFromAllByName: jest.fn().mockReturnValue({ type: classMirror, isChild: false }),
594
- });
595
-
596
- const result = new ReferenceBuilder().build('List<classname>');
597
-
598
- expect(result.referenceComponents).toHaveLength(2);
599
- expect(result.referenceComponents[0].referencedClass).toBe('classname_array');
600
- expect(result.entrypointReferenceObject.$ref).toBe('#/components/schemas/classname_array');
601
- expect((result.referenceComponents[0].schema as SchemaObjectArray).type).toBe('array');
602
- expect((result.referenceComponents[1].schema as SchemaObjectObject).properties).toHaveProperty('fieldName');
603
- });
604
-
605
- it('should resolve references to sets', function () {
606
- const classMirror = new ClassMirrorBuilder()
607
- .withName('classname')
608
- .addFiled(new FieldMirrorBuilder().withName('fieldName').withAccessModifier('public').build())
609
- .build();
610
-
611
- TypesRepository.getInstance = jest.fn().mockReturnValue({
612
- getFromAllByName: jest.fn().mockReturnValue({ type: classMirror, isChild: false }),
613
- });
614
-
615
- const result = new ReferenceBuilder().build('Set<classname>');
616
-
617
- expect(result.referenceComponents).toHaveLength(2);
618
- expect(result.referenceComponents[0].referencedClass).toBe('classname_array');
619
- expect(result.entrypointReferenceObject.$ref).toBe('#/components/schemas/classname_array');
620
- expect((result.referenceComponents[0].schema as SchemaObjectArray).type).toBe('array');
621
- expect((result.referenceComponents[1].schema as SchemaObjectObject).properties).toHaveProperty('fieldName');
622
- });
623
- });
624
-
625
- describe('References can override their type', () => {
626
- it('should correctly parse a reference with an overridden reference', function () {
627
- const classMirror = new ClassMirrorBuilder()
628
- .addFiled(
629
- new FieldMirrorBuilder()
630
- .withName('fieldName')
631
- .withType('Object')
632
- .withDocComment(
633
- new DocCommentBuilder()
634
- .addAnnotation(
635
- new DocCommentAnnotationBuilder().withName('http-schema').withBodyLines(['type: string']).build(),
636
- )
637
- .build(),
638
- )
639
- .build(),
640
- )
641
- .build();
642
-
643
- TypesRepository.getInstance = jest.fn().mockReturnValue({
644
- getFromAllByName: jest.fn().mockReturnValue({ type: classMirror, isChild: false }),
645
- });
646
-
647
- const result = new ReferenceBuilder().build('className');
648
-
649
- const schema = result.referenceComponents[0].schema as SchemaObjectObject;
650
- expect(schema.properties).toHaveProperty('fieldName');
651
- const fieldSchema = schema.properties!['fieldName'] as SchemaObjectObject;
652
- expect(fieldSchema.type).toBe('string');
653
- });
654
-
655
- it('should correctly parse a manually defined reference while parsing properties', function () {
656
- const mainClassMirror = new ClassMirrorBuilder()
657
- .withName('parent')
658
- .addFiled(
659
- new FieldMirrorBuilder()
660
- .withName('childClassMember')
661
- .withType('Object')
662
- .withDocComment(
663
- new DocCommentBuilder()
664
- .addAnnotation(
665
- new DocCommentAnnotationBuilder().withName('http-schema').withBodyLines(['ChildClass']).build(),
666
- )
667
- .build(),
668
- )
669
- .build(),
670
- )
671
- .build();
672
-
673
- const childClass = new ClassMirrorBuilder()
674
- .withName('child')
675
- .addFiled(
676
- new FieldMirrorBuilder()
677
- .withName('grandChildClassMember')
678
- .withReferencedType({
679
- type: 'GrandChildClass',
680
- rawDeclaration: 'GrandChildClass',
681
- })
682
- .build(),
683
- )
684
- .build();
685
-
686
- const grandChildClass = new ClassMirrorBuilder()
687
- .withName('grandchild')
688
- .addFiled(new FieldMirrorBuilder().withName('stringMember').withType('String').build())
689
- .build();
690
-
691
- TypesRepository.getInstance = jest.fn().mockReturnValue({
692
- getFromAllByName: jest
693
- .fn()
694
- .mockReturnValueOnce({ type: mainClassMirror, isChild: false })
695
- .mockReturnValueOnce({ type: childClass, isChild: false })
696
- .mockReturnValueOnce({ type: grandChildClass, isChild: false }),
697
- });
698
-
699
- const result = new ReferenceBuilder().build('className');
700
-
701
- expect(result.referenceComponents).toHaveLength(3);
702
- expect(result.referenceComponents.some((ref) => ref.referencedClass === 'parent')).toBe(true);
703
- expect(result.referenceComponents.some((ref) => ref.referencedClass === 'child')).toBe(true);
704
- expect(result.referenceComponents.some((ref) => ref.referencedClass === 'grandchild')).toBe(true);
705
- });
706
-
707
- it('should correctly parse a referenced property overridden inline', function () {
708
- const mainClassMirror = new ClassMirrorBuilder()
709
- .withName('parent')
710
- .addFiled(new FieldMirrorBuilder().withName('childClassMember').withType('Object').build())
711
- .build();
712
-
713
- const childClass = new ClassMirrorBuilder()
714
- .withName('child')
715
- .addFiled(
716
- new FieldMirrorBuilder()
717
- .withName('grandChildClassMember')
718
- .withReferencedType({
719
- type: 'GrandChildClass',
720
- rawDeclaration: 'GrandChildClass',
721
- })
722
- .build(),
723
- )
724
- .build();
725
-
726
- const grandChildClass = new ClassMirrorBuilder()
727
- .withName('grandchild')
728
- .addFiled(new FieldMirrorBuilder().withName('stringMember').withType('String').build())
729
- .build();
730
-
731
- TypesRepository.getInstance = jest.fn().mockReturnValue({
732
- getFromAllByName: jest
733
- .fn()
734
- .mockReturnValueOnce({ type: mainClassMirror, isChild: false })
735
- .mockReturnValueOnce({ type: childClass, isChild: false })
736
- .mockReturnValueOnce({ type: grandChildClass, isChild: false }),
737
- });
738
-
739
- const result = new ReferenceBuilder().build('className[childClassMember:ChildClass]');
740
-
741
- expect(result.referenceComponents).toHaveLength(3);
742
- expect(
743
- result.referenceComponents.some(
744
- (ref) => ref.referencedClass === 'parent_className[childClassMember:ChildClass]',
745
- ),
746
- ).toBe(true);
747
- expect(result.referenceComponents.some((ref) => ref.referencedClass === 'child')).toBe(true);
748
- expect(result.referenceComponents.some((ref) => ref.referencedClass === 'grandchild')).toBe(true);
749
- });
750
- });
751
- });