@redocly/openapi-docs 3.24.1 → 3.24.2

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 (260) hide show
  1. package/lib/telemetry/RedocTelemetry.js +1 -31
  2. package/package.json +4 -4
  3. package/lib/components/ApiInfo/__tests__/ApiInfo.test.d.ts +0 -1
  4. package/lib/components/ApiInfo/__tests__/ApiInfo.test.js +0 -46
  5. package/lib/components/Callbacks/__tests__/Callbacks.test.d.ts +0 -1
  6. package/lib/components/Callbacks/__tests__/Callbacks.test.js +0 -46
  7. package/lib/components/Content/__tests__/useAutoScroll.test.d.ts +0 -1
  8. package/lib/components/Content/__tests__/useAutoScroll.test.js +0 -88
  9. package/lib/components/ContentItem/__tests__/useIsExpanded.test.d.ts +0 -1
  10. package/lib/components/ContentItem/__tests__/useIsExpanded.test.js +0 -123
  11. package/lib/components/ContentItems/__tests__/Items.test.d.ts +0 -1
  12. package/lib/components/ContentItems/__tests__/Items.test.js +0 -66
  13. package/lib/components/ContentItems/__tests__/VirtualList.test.d.ts +0 -1
  14. package/lib/components/ContentItems/__tests__/VirtualList.test.js +0 -135
  15. package/lib/components/Discriminator/__tests__/DiscriminatorDropdown.test.d.ts +0 -1
  16. package/lib/components/Discriminator/__tests__/DiscriminatorDropdown.test.js +0 -63
  17. package/lib/components/Download/__tests__/DownloadSpecification.test.d.ts +0 -1
  18. package/lib/components/Download/__tests__/DownloadSpecification.test.js +0 -52
  19. package/lib/components/ExpandAllButton/__tests__/ExpandAllButton.test.d.ts +0 -1
  20. package/lib/components/ExpandAllButton/__tests__/ExpandAllButton.test.js +0 -60
  21. package/lib/components/ExpandAllButton/__tests__/helpers.test.d.ts +0 -1
  22. package/lib/components/ExpandAllButton/__tests__/helpers.test.js +0 -133
  23. package/lib/components/Language/__tests__/LanguageDropdown.test.d.ts +0 -1
  24. package/lib/components/Language/__tests__/LanguageDropdown.test.js +0 -23
  25. package/lib/components/Markdown/__tests__/Markdown.test.d.ts +0 -1
  26. package/lib/components/Markdown/__tests__/Markdown.test.js +0 -34
  27. package/lib/components/McpOverview/__tests__/McpOverview.test.d.ts +0 -1
  28. package/lib/components/McpOverview/__tests__/McpOverview.test.js +0 -66
  29. package/lib/components/McpTool/__tests__/McpPrompt.test.d.ts +0 -1
  30. package/lib/components/McpTool/__tests__/McpPrompt.test.js +0 -57
  31. package/lib/components/McpTool/__tests__/McpResource.test.d.ts +0 -1
  32. package/lib/components/McpTool/__tests__/McpResource.test.js +0 -81
  33. package/lib/components/McpTool/__tests__/McpTool.test.d.ts +0 -1
  34. package/lib/components/McpTool/__tests__/McpTool.test.js +0 -82
  35. package/lib/components/MediaTypeSwitch/__tests__/MediaTypesSwitch.test.d.ts +0 -1
  36. package/lib/components/MediaTypeSwitch/__tests__/MediaTypesSwitch.test.js +0 -79
  37. package/lib/components/OperationItem/__tests__/OperationItem.test.d.ts +0 -1
  38. package/lib/components/OperationItem/__tests__/OperationItem.test.js +0 -70
  39. package/lib/components/OperationItem/__tests__/__mocks__/mock-intersection-observer.d.ts +0 -16
  40. package/lib/components/OperationItem/__tests__/__mocks__/mock-intersection-observer.js +0 -42
  41. package/lib/components/Overview/__tests__/Overview.test.d.ts +0 -1
  42. package/lib/components/Overview/__tests__/Overview.test.js +0 -59
  43. package/lib/components/PayloadSamples/__tests__/Example.test.d.ts +0 -1
  44. package/lib/components/PayloadSamples/__tests__/Example.test.js +0 -36
  45. package/lib/components/PayloadSamples/__tests__/ExampleValue.test.d.ts +0 -1
  46. package/lib/components/PayloadSamples/__tests__/ExampleValue.test.js +0 -197
  47. package/lib/components/PayloadSamples/__tests__/PayloadSamples.test.d.ts +0 -1
  48. package/lib/components/PayloadSamples/__tests__/PayloadSamples.test.js +0 -38
  49. package/lib/components/PropertyDetails/__tests__/Extensions.test.d.ts +0 -1
  50. package/lib/components/PropertyDetails/__tests__/Extensions.test.js +0 -21
  51. package/lib/components/PropertyDetails/__tests__/FieldDetail.test.d.ts +0 -1
  52. package/lib/components/PropertyDetails/__tests__/FieldDetail.test.js +0 -52
  53. package/lib/components/PropertyDetails/__tests__/FieldDetails.test.d.ts +0 -1
  54. package/lib/components/PropertyDetails/__tests__/FieldDetails.test.js +0 -191
  55. package/lib/components/PropertyDetails/__tests__/PropertyDetails.test.d.ts +0 -1
  56. package/lib/components/PropertyDetails/__tests__/PropertyDetails.test.js +0 -365
  57. package/lib/components/PropertyDetails/__tests__/cycleColorsByLevel.test.d.ts +0 -1
  58. package/lib/components/PropertyDetails/__tests__/cycleColorsByLevel.test.js +0 -23
  59. package/lib/components/RedoclyOpenAPIDocs/__tests__/AppProvider.test.d.ts +0 -1
  60. package/lib/components/RedoclyOpenAPIDocs/__tests__/AppProvider.test.js +0 -16
  61. package/lib/components/RedoclyOpenAPIDocs/__tests__/RedoclyOpenAPIDocs.test.d.ts +0 -1
  62. package/lib/components/RedoclyOpenAPIDocs/__tests__/RedoclyOpenAPIDocs.test.js +0 -104
  63. package/lib/components/RenderHook/__tests__/RenderHook.test.d.ts +0 -1
  64. package/lib/components/RenderHook/__tests__/RenderHook.test.js +0 -15
  65. package/lib/components/Replay/__tests__/utils.test.d.ts +0 -1
  66. package/lib/components/Replay/__tests__/utils.test.js +0 -526
  67. package/lib/components/Request/__tests__/RequestDetails.test.d.ts +0 -1
  68. package/lib/components/Request/__tests__/RequestDetails.test.js +0 -98
  69. package/lib/components/RequestSamples/__tests__/Example.test.d.ts +0 -1
  70. package/lib/components/RequestSamples/__tests__/Example.test.js +0 -384
  71. package/lib/components/RequestSamples/__tests__/RequestSamples.test.d.ts +0 -1
  72. package/lib/components/RequestSamples/__tests__/RequestSamples.test.js +0 -226
  73. package/lib/components/RequestSamples/__tests__/useCodeSamples.test.d.ts +0 -1
  74. package/lib/components/RequestSamples/__tests__/useCodeSamples.test.js +0 -64
  75. package/lib/components/ResponseSamples/__tests__/ResponseSamples.test.d.ts +0 -1
  76. package/lib/components/ResponseSamples/__tests__/ResponseSamples.test.js +0 -29
  77. package/lib/components/Responses/__tests__/OperationResponseList.test.d.ts +0 -1
  78. package/lib/components/Responses/__tests__/OperationResponseList.test.js +0 -89
  79. package/lib/components/Responses/__tests__/ResponseDetails.test.d.ts +0 -1
  80. package/lib/components/Responses/__tests__/ResponseDetails.test.js +0 -111
  81. package/lib/components/Responses/__tests__/ResponsesHeaders.test.d.ts +0 -1
  82. package/lib/components/Responses/__tests__/ResponsesHeaders.test.js +0 -26
  83. package/lib/components/Schema/__tests__/ArraySchema.test.d.ts +0 -1
  84. package/lib/components/Schema/__tests__/ArraySchema.test.js +0 -93
  85. package/lib/components/Schema/__tests__/ObjectSchema.test.d.ts +0 -1
  86. package/lib/components/Schema/__tests__/ObjectSchema.test.js +0 -115
  87. package/lib/components/Schema/__tests__/OneOfSchema.test.d.ts +0 -1
  88. package/lib/components/Schema/__tests__/OneOfSchema.test.js +0 -33
  89. package/lib/components/Schema/__tests__/Schema.test.d.ts +0 -1
  90. package/lib/components/Schema/__tests__/Schema.test.js +0 -67
  91. package/lib/components/Schema/__tests__/useOneOfLocationIdx.test.d.ts +0 -1
  92. package/lib/components/Schema/__tests__/useOneOfLocationIdx.test.js +0 -22
  93. package/lib/components/SchemaCatalogLink/__tests__/SchemaCatalogLink.test.d.ts +0 -1
  94. package/lib/components/SchemaCatalogLink/__tests__/SchemaCatalogLink.test.js +0 -95
  95. package/lib/components/Security/__tests__/Security.test.d.ts +0 -1
  96. package/lib/components/Security/__tests__/Security.test.js +0 -38
  97. package/lib/components/Security/__tests__/SecurityButton.test.d.ts +0 -1
  98. package/lib/components/Security/__tests__/SecurityButton.test.js +0 -92
  99. package/lib/components/Security/__tests__/SecurityModal.test.d.ts +0 -1
  100. package/lib/components/Security/__tests__/SecurityModal.test.js +0 -172
  101. package/lib/components/ServerList/__tests__/ServerList.test.d.ts +0 -1
  102. package/lib/components/ServerList/__tests__/ServerList.test.js +0 -83
  103. package/lib/components/Tabs/__tests__/Tabs.test.d.ts +0 -1
  104. package/lib/components/Tabs/__tests__/Tabs.test.js +0 -27
  105. package/lib/components/ViewNested/__tests__/ViewNested.test.d.ts +0 -1
  106. package/lib/components/ViewNested/__tests__/ViewNested.test.js +0 -42
  107. package/lib/components/__tests__/Samples/ExampleSwitch.test.d.ts +0 -1
  108. package/lib/components/__tests__/Samples/ExampleSwitch.test.js +0 -45
  109. package/lib/components/__tests__/Samples/use-example-key.test.d.ts +0 -1
  110. package/lib/components/__tests__/Samples/use-example-key.test.js +0 -28
  111. package/lib/components/__tests__/common/ClearButton.test.d.ts +0 -1
  112. package/lib/components/__tests__/common/ClearButton.test.js +0 -18
  113. package/lib/components/__tests__/common/Dropdown.test.d.ts +0 -1
  114. package/lib/components/__tests__/common/Dropdown.test.js +0 -52
  115. package/lib/components/__tests__/mocks/examples.d.ts +0 -4
  116. package/lib/components/__tests__/mocks/examples.js +0 -115
  117. package/lib/components/common/__tests__/Dropdown.test.d.ts +0 -1
  118. package/lib/components/common/__tests__/Dropdown.test.js +0 -129
  119. package/lib/components/common/__tests__/LinkToField.test.d.ts +0 -1
  120. package/lib/components/common/__tests__/LinkToField.test.js +0 -39
  121. package/lib/jotai/__tests__/app.test.d.ts +0 -1
  122. package/lib/jotai/__tests__/app.test.js +0 -53
  123. package/lib/models/__tests__/Callback.test.d.ts +0 -1
  124. package/lib/models/__tests__/Callback.test.js +0 -15
  125. package/lib/models/__tests__/FieldModel.test.d.ts +0 -1
  126. package/lib/models/__tests__/FieldModel.test.js +0 -117
  127. package/lib/models/__tests__/MediaContent.test.d.ts +0 -1
  128. package/lib/models/__tests__/MediaContent.test.js +0 -105
  129. package/lib/models/__tests__/Operation.test.d.ts +0 -1
  130. package/lib/models/__tests__/Operation.test.js +0 -459
  131. package/lib/models/__tests__/Response.test.d.ts +0 -1
  132. package/lib/models/__tests__/Response.test.js +0 -221
  133. package/lib/models/__tests__/Schema.circular.test.d.ts +0 -1
  134. package/lib/models/__tests__/Schema.circular.test.js +0 -694
  135. package/lib/models/__tests__/Schema.test.d.ts +0 -1
  136. package/lib/models/__tests__/Schema.test.js +0 -1395
  137. package/lib/models/__tests__/example.test.d.ts +0 -1
  138. package/lib/models/__tests__/example.test.js +0 -90
  139. package/lib/models/__tests__/group.test.d.ts +0 -1
  140. package/lib/models/__tests__/group.test.js +0 -52
  141. package/lib/models/__tests__/helpers.d.ts +0 -5
  142. package/lib/models/__tests__/helpers.js +0 -62
  143. package/lib/models/__tests__/request.test.d.ts +0 -1
  144. package/lib/models/__tests__/request.test.js +0 -119
  145. package/lib/services/__tests__/OpenAPIParser.test.d.ts +0 -1
  146. package/lib/services/__tests__/OpenAPIParser.test.js +0 -80
  147. package/lib/services/__tests__/check.test.d.ts +0 -1
  148. package/lib/services/__tests__/check.test.js +0 -22
  149. package/lib/services/__tests__/utils.test.d.ts +0 -1
  150. package/lib/services/__tests__/utils.test.js +0 -42
  151. package/lib/services/code-samples/__tests__/apply-environments.test.d.ts +0 -1
  152. package/lib/services/code-samples/__tests__/apply-environments.test.js +0 -64
  153. package/lib/services/code-samples/__tests__/build-code-samples.test.d.ts +0 -1
  154. package/lib/services/code-samples/__tests__/build-code-samples.test.js +0 -70
  155. package/lib/services/code-samples/__tests__/convertSampleToString.test.d.ts +0 -1
  156. package/lib/services/code-samples/__tests__/convertSampleToString.test.js +0 -116
  157. package/lib/services/code-samples/__tests__/generator-data-value.test.d.ts +0 -1
  158. package/lib/services/code-samples/__tests__/generator-data-value.test.js +0 -277
  159. package/lib/services/code-samples/__tests__/generator-serialized-value.test.d.ts +0 -1
  160. package/lib/services/code-samples/__tests__/generator-serialized-value.test.js +0 -258
  161. package/lib/services/code-samples/__tests__/generator-value.test.d.ts +0 -1
  162. package/lib/services/code-samples/__tests__/generator-value.test.js +0 -273
  163. package/lib/services/code-samples/__tests__/generator.test.d.ts +0 -249
  164. package/lib/services/code-samples/__tests__/generator.test.js +0 -1201
  165. package/lib/services/code-samples/__tests__/get-example-value-by-mime-type.test.d.ts +0 -1
  166. package/lib/services/code-samples/__tests__/get-example-value-by-mime-type.test.js +0 -31
  167. package/lib/services/code-samples/httpsnippet/__tests__/device-authorization.test.d.ts +0 -1
  168. package/lib/services/code-samples/httpsnippet/__tests__/device-authorization.test.js +0 -222
  169. package/lib/services/code-samples/httpsnippet/helpers/__tests__/code-helpers.test.d.ts +0 -1
  170. package/lib/services/code-samples/httpsnippet/helpers/__tests__/code-helpers.test.js +0 -129
  171. package/lib/services/code-samples/httpsnippet/helpers/__tests__/string-utility.test.d.ts +0 -1
  172. package/lib/services/code-samples/httpsnippet/helpers/__tests__/string-utility.test.js +0 -49
  173. package/lib/services/code-samples/httpsnippet/targets/csharp/__tests__/httpclient.test.d.ts +0 -1
  174. package/lib/services/code-samples/httpsnippet/targets/csharp/__tests__/httpclient.test.js +0 -172
  175. package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/__tests__/httpclient.test.d.ts +0 -1
  176. package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/__tests__/httpclient.test.js +0 -172
  177. package/lib/services/code-samples/httpsnippet/targets/go/__tests__/native.test.d.ts +0 -1
  178. package/lib/services/code-samples/httpsnippet/targets/go/__tests__/native.test.js +0 -130
  179. package/lib/services/code-samples/httpsnippet/targets/java/__tests__/httpclient.test.d.ts +0 -1
  180. package/lib/services/code-samples/httpsnippet/targets/java/__tests__/httpclient.test.js +0 -191
  181. package/lib/services/code-samples/httpsnippet/targets/java8/__tests__/apachehttp.test.d.ts +0 -1
  182. package/lib/services/code-samples/httpsnippet/targets/java8/__tests__/apachehttp.test.js +0 -172
  183. package/lib/services/code-samples/httpsnippet/targets/javascript/__tests__/fetch.test.d.ts +0 -1
  184. package/lib/services/code-samples/httpsnippet/targets/javascript/__tests__/fetch.test.js +0 -85
  185. package/lib/services/code-samples/httpsnippet/targets/node/__tests__/fetch.test.d.ts +0 -1
  186. package/lib/services/code-samples/httpsnippet/targets/node/__tests__/fetch.test.js +0 -85
  187. package/lib/services/code-samples/httpsnippet/targets/php/__tests__/curl.test.d.ts +0 -1
  188. package/lib/services/code-samples/httpsnippet/targets/php/__tests__/curl.test.js +0 -126
  189. package/lib/services/code-samples/httpsnippet/targets/python/__tests__/requests.test.d.ts +0 -1
  190. package/lib/services/code-samples/httpsnippet/targets/python/__tests__/requests.test.js +0 -105
  191. package/lib/services/code-samples/httpsnippet/targets/r/__tests__/httr.test.d.ts +0 -1
  192. package/lib/services/code-samples/httpsnippet/targets/r/__tests__/httr.test.js +0 -126
  193. package/lib/services/code-samples/httpsnippet/targets/ruby/__tests__/native.test.d.ts +0 -1
  194. package/lib/services/code-samples/httpsnippet/targets/ruby/__tests__/native.test.js +0 -129
  195. package/lib/services/code-samples/httpsnippet/targets/shell/__tests__/curl.test.d.ts +0 -1
  196. package/lib/services/code-samples/httpsnippet/targets/shell/__tests__/curl.test.js +0 -129
  197. package/lib/services/config-options/__tests__/helpers.test.d.ts +0 -1
  198. package/lib/services/config-options/__tests__/helpers.test.js +0 -234
  199. package/lib/services/history/__tests__/helpers.test.d.ts +0 -1
  200. package/lib/services/history/__tests__/helpers.test.js +0 -19
  201. package/lib/services/menu/__tests__/buildNestedTagsItems.test.d.ts +0 -1
  202. package/lib/services/menu/__tests__/buildNestedTagsItems.test.js +0 -109
  203. package/lib/services/menu/__tests__/builder.test.d.ts +0 -1
  204. package/lib/services/menu/__tests__/builder.test.js +0 -307
  205. package/lib/services/menu/__tests__/operation.test.d.ts +0 -1
  206. package/lib/services/menu/__tests__/operation.test.js +0 -240
  207. package/lib/services/menu/__tests__/tags.test.d.ts +0 -1
  208. package/lib/services/menu/__tests__/tags.test.js +0 -71
  209. package/lib/telemetry/__tests__/RedocTelemetry.test.d.ts +0 -1
  210. package/lib/telemetry/__tests__/RedocTelemetry.test.js +0 -107
  211. package/lib/testProviders.d.ts +0 -6
  212. package/lib/testProviders.js +0 -14
  213. package/lib/utils/__tests__/areArraysEqual.test.d.ts +0 -1
  214. package/lib/utils/__tests__/areArraysEqual.test.js +0 -33
  215. package/lib/utils/__tests__/argValuesHelpers.d.ts +0 -1
  216. package/lib/utils/__tests__/argValuesHelpers.js +0 -56
  217. package/lib/utils/__tests__/calculateMaxLength.test.d.ts +0 -1
  218. package/lib/utils/__tests__/calculateMaxLength.test.js +0 -119
  219. package/lib/utils/__tests__/configure-helpers.test.d.ts +0 -1
  220. package/lib/utils/__tests__/configure-helpers.test.js +0 -356
  221. package/lib/utils/__tests__/convertSwagger2OpenAPI.test.d.ts +0 -1
  222. package/lib/utils/__tests__/convertSwagger2OpenAPI.test.js +0 -392
  223. package/lib/utils/__tests__/debounce.test.d.ts +0 -1
  224. package/lib/utils/__tests__/debounce.test.js +0 -54
  225. package/lib/utils/__tests__/debug.test.d.ts +0 -1
  226. package/lib/utils/__tests__/debug.test.js +0 -23
  227. package/lib/utils/__tests__/dom.test.d.ts +0 -1
  228. package/lib/utils/__tests__/dom.test.js +0 -108
  229. package/lib/utils/__tests__/getBreadcrumbs.test.d.ts +0 -1
  230. package/lib/utils/__tests__/getBreadcrumbs.test.js +0 -98
  231. package/lib/utils/__tests__/hasNestedFields.test.d.ts +0 -1
  232. package/lib/utils/__tests__/hasNestedFields.test.js +0 -147
  233. package/lib/utils/__tests__/helpers.test.d.ts +0 -1
  234. package/lib/utils/__tests__/helpers.test.js +0 -174
  235. package/lib/utils/__tests__/isMobile.test.d.ts +0 -1
  236. package/lib/utils/__tests__/isMobile.test.js +0 -28
  237. package/lib/utils/__tests__/loadAndBundleSpec.test.d.ts +0 -1
  238. package/lib/utils/__tests__/loadAndBundleSpec.test.js +0 -22
  239. package/lib/utils/__tests__/local-storage.test.d.ts +0 -1
  240. package/lib/utils/__tests__/local-storage.test.js +0 -48
  241. package/lib/utils/__tests__/object.test.d.ts +0 -1
  242. package/lib/utils/__tests__/object.test.js +0 -45
  243. package/lib/utils/__tests__/openapi.test.d.ts +0 -1
  244. package/lib/utils/__tests__/openapi.test.js +0 -1378
  245. package/lib/utils/__tests__/path.test.d.ts +0 -1
  246. package/lib/utils/__tests__/path.test.js +0 -16
  247. package/lib/utils/__tests__/queryString.test.d.ts +0 -1
  248. package/lib/utils/__tests__/queryString.test.js +0 -60
  249. package/lib/utils/__tests__/replaceVariables.test.d.ts +0 -1
  250. package/lib/utils/__tests__/replaceVariables.test.js +0 -46
  251. package/lib/utils/__tests__/simplifyAstStructure.test.d.ts +0 -1
  252. package/lib/utils/__tests__/simplifyAstStructure.test.js +0 -26
  253. package/lib/utils/__tests__/sort.test.d.ts +0 -1
  254. package/lib/utils/__tests__/sort.test.js +0 -16
  255. package/lib/utils/__tests__/string.test.d.ts +0 -1
  256. package/lib/utils/__tests__/string.test.js +0 -16
  257. package/lib/utils/__tests__/theme-helpers.test.d.ts +0 -1
  258. package/lib/utils/__tests__/theme-helpers.test.js +0 -24
  259. package/lib/utils/__tests__/url.test.d.ts +0 -1
  260. package/lib/utils/__tests__/url.test.js +0 -134
@@ -1,79 +0,0 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { act, render } from '@testing-library/react';
3
- import { MediaTypesSwitch } from '../MediaTypesSwitch.js';
4
- import { getOperation } from '../../../models/index.js';
5
- import { normalizeOptions, OpenAPIParser } from '../../../services/index.js';
6
- import testDefinition from './fixtures/test-definition.json';
7
- import { withTestProviders } from '../../../testProviders.js';
8
- describe('Components', () => {
9
- describe('MediaTypesSwitch', () => {
10
- const options = normalizeOptions({});
11
- const parser = new OpenAPIParser(testDefinition, undefined, options);
12
- let operation;
13
- beforeEach(() => {
14
- operation = getOperation(parser, {
15
- pointer: '#/paths/~1test/get',
16
- pathName: '/test',
17
- httpVerb: 'GET',
18
- pathParameters: [],
19
- pathServers: [],
20
- isWebhook: false,
21
- isAdditionalOperation: false,
22
- ...testDefinition.paths['/test'].get,
23
- }, undefined, options, '');
24
- });
25
- test('renders with default media type by default', () => {
26
- const childrenFn = vi.fn((mimeType) => _jsxs(_Fragment, { children: ["children: ", mimeType.name] }));
27
- const renderSelectFn = vi.fn(() => null);
28
- const { getByText } = render(withTestProviders(_jsx(MediaTypesSwitch, { renderSelect: renderSelectFn, content: operation.requestBody?.content, children: childrenFn }), { definition: parser.definition }));
29
- expect(renderSelectFn.mock.calls[0][0].options).toEqual([
30
- { idx: 0, value: 'application/json' },
31
- { idx: 1, value: 'application/xml' },
32
- ]);
33
- expect(getByText('children: application/json')).toBeInTheDocument();
34
- });
35
- test('withLabel renders label', () => {
36
- const childrenFn = vi.fn((mimeType) => _jsxs(_Fragment, { children: ["children: ", mimeType.name] }));
37
- const renderSelectFn = vi.fn(() => _jsx(_Fragment, { children: "dropdown" }));
38
- const { getByText } = render(withTestProviders(_jsx(MediaTypesSwitch, { withLabel: true, renderSelect: renderSelectFn, content: operation.requestBody?.content, children: childrenFn }), { definition: parser.definition }));
39
- expect(getByText('Content type')).toBeInTheDocument();
40
- });
41
- test('should try to restore scroll on switch', async () => {
42
- const childrenFn = vi.fn((mimeType) => _jsxs(_Fragment, { children: ["children: ", mimeType.name] }));
43
- const renderSelectFn = vi.fn(() => (_jsx(_Fragment, { children: "dropdown" })));
44
- const { findByText, container } = render(withTestProviders(_jsx(MediaTypesSwitch, { withLabel: true, renderSelect: renderSelectFn, content: operation.requestBody?.content, children: childrenFn }), { definition: parser.definition }));
45
- // Create a mock implementation of window.scrollBy
46
- const scrollByMock = vi.fn();
47
- Object.defineProperty(window, 'scrollBy', { value: scrollByMock });
48
- const rectMock = vi.fn(() => {
49
- return (rectMock.mock.calls.length > 1 ? { y: 150 } : { y: 100 });
50
- });
51
- vi.spyOn(container?.firstElementChild, 'getBoundingClientRect').mockImplementation(rectMock);
52
- act(() => {
53
- const selectProps = renderSelectFn.mock.calls[0][0];
54
- selectProps.onChange(selectProps.options[1]);
55
- });
56
- await findByText('children: application/xml');
57
- await new Promise((resolve) => setTimeout(resolve, 500)); // sleep
58
- expect(rectMock).toHaveBeenCalledTimes(2);
59
- expect(scrollByMock).toHaveBeenCalledWith(0, 50);
60
- });
61
- test('should not throw and render null for empty media types', () => {
62
- const childrenFn = vi.fn((mimeType) => _jsxs(_Fragment, { children: ["children: ", mimeType.name] }));
63
- const renderSelectFn = vi.fn(() => null);
64
- const { container } = render(withTestProviders(_jsx(MediaTypesSwitch, { renderSelect: renderSelectFn,
65
- // @ts-ignore invalid content shape
66
- content: null, children: childrenFn }), { definition: parser.definition }));
67
- expect(container.firstChild).toBeNull();
68
- const { container: container2 } = render(withTestProviders(_jsx(MediaTypesSwitch, { renderSelect: renderSelectFn,
69
- // @ts-expect-error invalid content shape
70
- content: { mediaTypes: null }, children: childrenFn }), { definition: parser.definition }));
71
- expect(container2.firstChild).toBeNull();
72
- const { container: container3 } = render(withTestProviders(_jsx(MediaTypesSwitch, { renderSelect: renderSelectFn,
73
- // @ts-expect-error invalid content shape
74
- content: { mediaTypes: [] }, children: childrenFn }), { definition: parser.definition }));
75
- expect(container3.firstChild).toBeNull();
76
- });
77
- });
78
- });
79
- //# sourceMappingURL=MediaTypesSwitch.test.js.map
@@ -1,70 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { render } from '@testing-library/react';
3
- import { OperationItem } from '../OperationItem.js';
4
- import { normalizeOptions } from '../../../services/index.js';
5
- import spec from './fixtures/petstore.json';
6
- import definition from './fixtures/operationDefinition.json';
7
- import { environmentAtom } from '../../../jotai/app.js';
8
- import { globalStoreAtom } from '../../../jotai/store.js';
9
- import { allOperationsAtom } from '../../../jotai/replay.js';
10
- import { MockIntersectionObserver } from './__mocks__/mock-intersection-observer.js';
11
- import { TestBrowserRouter } from '../../../testProviders.js';
12
- vi.mock('jotai', async () => ({
13
- ...(await vi.importActual('jotai')),
14
- useAtomValue: vi.fn((a) => {
15
- if (a === globalStoreAtom) {
16
- return {
17
- parser: {
18
- definition: spec,
19
- },
20
- options: normalizeOptions({
21
- codeSamples: {
22
- languages: [{ lang: 'curl', label: 'curl' }],
23
- },
24
- }),
25
- };
26
- }
27
- if (a === environmentAtom) {
28
- return [{}, ''];
29
- }
30
- if (a === allOperationsAtom) {
31
- return [];
32
- }
33
- return {};
34
- }),
35
- useAtom: vi.fn((a) => {
36
- if (a === environmentAtom) {
37
- return [[{ server: {} }], vi.fn()];
38
- }
39
- return [
40
- {
41
- activeOneOf: { '/paths/~1pet/post': 0 },
42
- requestValues: {},
43
- request: { expandedFields: {} },
44
- response: { expandedFields: {} },
45
- activeLanguage: 'curl',
46
- },
47
- vi.fn(),
48
- ];
49
- }),
50
- }));
51
- describe('OperationItem', () => {
52
- beforeAll(() => {
53
- window.IntersectionObserver = MockIntersectionObserver;
54
- });
55
- it('should render badges with correct position', () => {
56
- const { getByTestId } = render(_jsx(OperationItem, { item: {
57
- operationDefinition: definition,
58
- parent: undefined,
59
- href: 'test',
60
- } }), {
61
- wrapper: TestBrowserRouter,
62
- });
63
- const parentElement = getByTestId('operation-item-header');
64
- const childNodes = parentElement.childNodes;
65
- expect(childNodes[1].textContent).toBe('Alpha');
66
- expect(childNodes[3].textContent).toBe('Beta');
67
- expect(childNodes[4].textContent).toBe('Gamma');
68
- });
69
- });
70
- //# sourceMappingURL=OperationItem.test.js.map
@@ -1,16 +0,0 @@
1
- export declare class MockIntersectionObserver {
2
- readonly root: Element | Document | null;
3
- readonly rootMargin: string;
4
- readonly scrollMargin: string;
5
- readonly thresholds: ReadonlyArray<number>;
6
- private viewPort;
7
- private entries;
8
- private readonly callback;
9
- constructor(callback: IntersectionObserverCallback, options?: IntersectionObserverInit);
10
- private intersect;
11
- isInViewPort(target: HTMLElement): boolean;
12
- observe(target: HTMLElement): void;
13
- unobserve(target: HTMLElement): void;
14
- disconnect(): void;
15
- takeRecords(): any[];
16
- }
@@ -1,42 +0,0 @@
1
- export class MockIntersectionObserver {
2
- root;
3
- rootMargin;
4
- scrollMargin;
5
- thresholds;
6
- viewPort;
7
- entries;
8
- callback;
9
- constructor(callback, options) {
10
- this.viewPort = options?.root ? options.root : window;
11
- this.entries = [];
12
- this.root = null;
13
- this.rootMargin = '0px';
14
- this.scrollMargin = '';
15
- this.thresholds = [1];
16
- this.callback = callback;
17
- this.viewPort.addEventListener('scroll', this.intersect);
18
- }
19
- intersect = () => {
20
- this.entries.map((entry) => {
21
- entry.isIntersecting = this.isInViewPort(entry.target);
22
- });
23
- this.callback(this.entries, this);
24
- };
25
- isInViewPort(target) {
26
- return target.id !== 'toc-0';
27
- }
28
- observe(target) {
29
- this.entries.push({ isIntersecting: false, target });
30
- }
31
- unobserve(target) {
32
- this.entries = this.entries.filter((ob) => ob.target !== target);
33
- }
34
- disconnect() {
35
- this.viewPort.removeEventListener('scroll', this.intersect);
36
- this.entries = [];
37
- }
38
- takeRecords() {
39
- return this.entries;
40
- }
41
- }
42
- //# sourceMappingURL=mock-intersection-observer.js.map
@@ -1 +0,0 @@
1
- export {};
@@ -1,59 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { render } from '@testing-library/react';
3
- import { Overview } from '../Overview.js';
4
- const mockTranslate = (key, defaultValue) => defaultValue || key;
5
- describe('Overview', () => {
6
- it('should render correctly with full data', () => {
7
- const info = {
8
- title: 'Test API',
9
- version: '1.0.0',
10
- description: 'Test description',
11
- contact: {
12
- name: 'Test Contact',
13
- url: 'https://example.com',
14
- email: 'test@example.com',
15
- },
16
- license: {
17
- name: 'MIT',
18
- url: 'https://opensource.org/licenses/MIT',
19
- identifier: 'MIT',
20
- },
21
- termsOfService: 'https://example.com/terms',
22
- };
23
- const { container } = render(_jsx(Overview, { info: info, translate: mockTranslate }));
24
- expect(container).toMatchSnapshot();
25
- });
26
- it('should render correctly with partial data', () => {
27
- const info = {
28
- title: 'Test API',
29
- version: '1.0.0',
30
- };
31
- const { container } = render(_jsx(Overview, { info: info, translate: mockTranslate }));
32
- expect(container).toMatchSnapshot();
33
- });
34
- it('should render correctly with contact data but without a name', () => {
35
- const info = {
36
- title: 'Test API',
37
- version: '1.0.0',
38
- contact: {
39
- url: 'https://example.com',
40
- email: 'test@example.com',
41
- },
42
- };
43
- const { container } = render(_jsx(Overview, { info: info, translate: mockTranslate }));
44
- expect(container).toMatchSnapshot();
45
- });
46
- it('should render license with name and url when identifier is not present', () => {
47
- const info = {
48
- title: 'Test API',
49
- version: '1.0.0',
50
- license: {
51
- name: 'Apache 2.0',
52
- url: 'https://www.apache.org/licenses/LICENSE-2.0.html',
53
- },
54
- };
55
- const { container } = render(_jsx(Overview, { info: info, translate: mockTranslate }));
56
- expect(container).toMatchSnapshot();
57
- });
58
- });
59
- //# sourceMappingURL=Overview.test.js.map
@@ -1,36 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { render } from '@testing-library/react';
3
- import * as Jotai from 'jotai';
4
- import { Example } from '../Example.js';
5
- import { normalizeOptions, OpenAPIParser } from '../../../services/index.js';
6
- import { getExamples } from '../../../models/index.js';
7
- import testDefinition from './fixtures/mediaTypeUrlencoded.json';
8
- describe('Example component', () => {
9
- const opts = normalizeOptions({});
10
- const parser = new OpenAPIParser(testDefinition, undefined, opts);
11
- it('render component without error when `externalValue` is pdf file', () => {
12
- const example = getExamples({
13
- parser,
14
- infoOrRef: {
15
- summary: 'A sample file',
16
- externalValue: 'https://assets.identi.tech/dummy.pdf',
17
- },
18
- mime: 'application/pdf',
19
- });
20
- const { container } = render(_jsx(Jotai.Provider, { children: _jsx(Example, { example: example, mimeType: example.mime, onCopyClick: vi.fn() }) }));
21
- expect(container).toMatchSnapshot();
22
- });
23
- it('render component with `externalValue`', () => {
24
- const example = getExamples({
25
- parser,
26
- infoOrRef: {
27
- summary: 'A sample json',
28
- externalValue: 'https://jsonplaceholder.typicode.com/todos/1',
29
- },
30
- mime: 'application/json',
31
- });
32
- const { container } = render(_jsx(Jotai.Provider, { children: _jsx(Example, { example: example, mimeType: example.mime, onCopyClick: vi.fn() }) }));
33
- expect(container).toMatchSnapshot();
34
- });
35
- });
36
- //# sourceMappingURL=Example.test.js.map
@@ -1,197 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { render } from '@testing-library/react';
3
- import { vi } from 'vitest';
4
- import * as Jotai from 'jotai';
5
- import { ExampleValue } from '../ExampleValue.js';
6
- import { globalOptionsAtom } from '../../../jotai/store.js';
7
- import { normalizeOptions } from '../../../services/index.js';
8
- vi.mock('@redocly/theme/components/JsonViewer/JsonViewer', () => ({
9
- JsonViewer: vi.fn(({ data, expandLevel, onCopyClick, onPanelToggle }) => (_jsxs("div", { "data-testid": "json-viewer", "data-expand-level": expandLevel, children: [_jsx("pre", { "data-testid": "json-viewer-data", children: JSON.stringify(data, null, 2) }), onCopyClick && _jsx("button", { "data-testid": "copy-button", onClick: onCopyClick }), onPanelToggle && _jsx("button", { "data-testid": "panel-toggle", onClick: () => onPanelToggle(true) })] }))),
10
- }));
11
- vi.mock('../styled.js', () => ({
12
- StyledCodeBlock: vi.fn(({ source, lang, header }) => (_jsxs("div", { "data-testid": "code-block", "data-lang": lang, children: [_jsx("pre", { children: source }), header?.controls?.copy && (_jsx("button", { "data-testid": "code-block-copy", onClick: header.controls.copy.onClick }))] }))),
13
- }));
14
- vi.mock('jotai', async () => {
15
- const actual = await vi.importActual('jotai');
16
- return {
17
- ...actual,
18
- useAtomValue: vi.fn(),
19
- };
20
- });
21
- describe('ExampleValue', () => {
22
- const mockUseAtomValue = Jotai.useAtomValue;
23
- const options = normalizeOptions({});
24
- beforeEach(async () => {
25
- vi.clearAllMocks();
26
- const actualJotai = await vi.importActual('jotai');
27
- mockUseAtomValue.mockImplementation((atom) => {
28
- if (atom === globalOptionsAtom) {
29
- return {
30
- ...options,
31
- jsonSamplesExpandLevel: 2,
32
- };
33
- }
34
- return actualJotai.useAtomValue(atom);
35
- });
36
- });
37
- describe('JSON parsing for application/json', () => {
38
- it('should parse valid JSON string and pass parsed object to JsonViewer', () => {
39
- const validJsonString = '{"name":"Test User","value":"premium","count":5}';
40
- const props = {
41
- value: validJsonString,
42
- mimeType: 'application/json',
43
- onCopyClick: vi.fn(),
44
- };
45
- const { getByTestId } = render(_jsx(Jotai.Provider, { children: _jsx(ExampleValue, { ...props }) }));
46
- const jsonData = getByTestId('json-viewer-data');
47
- const parsedData = JSON.parse(jsonData.textContent || '{}');
48
- expect(parsedData).toEqual({
49
- name: 'Test User',
50
- value: 'premium',
51
- count: 5,
52
- });
53
- });
54
- it('should use value as-is when it is already an object (not a string)', () => {
55
- const objectValue = { name: 'Test User', value: 'premium', count: 5 };
56
- const props = {
57
- value: objectValue,
58
- mimeType: 'application/json',
59
- onCopyClick: vi.fn(),
60
- };
61
- const { getByTestId } = render(_jsx(Jotai.Provider, { children: _jsx(ExampleValue, { ...props }) }));
62
- const jsonData = getByTestId('json-viewer-data');
63
- const parsedData = JSON.parse(jsonData.textContent || '{}');
64
- expect(parsedData).toEqual(objectValue);
65
- });
66
- it('should fallback to original value when JSON string is invalid', () => {
67
- const invalidJsonString = '{"name":"Test User",invalid json}';
68
- const props = {
69
- value: invalidJsonString,
70
- mimeType: 'application/json',
71
- onCopyClick: vi.fn(),
72
- };
73
- const { getByTestId } = render(_jsx(Jotai.Provider, { children: _jsx(ExampleValue, { ...props }) }));
74
- const jsonData = getByTestId('json-viewer-data');
75
- const parsedData = JSON.parse(jsonData.textContent || '');
76
- expect(parsedData).toBe(invalidJsonString);
77
- });
78
- });
79
- describe('XML handling for application/xml', () => {
80
- it('should wrap object in root tag and convert to XML (dataValue case)', () => {
81
- const objectValue = { name: 'Test User', value: 'premium' };
82
- const props = {
83
- value: objectValue,
84
- mimeType: 'application/xml',
85
- onCopyClick: vi.fn(),
86
- };
87
- const { getByTestId } = render(_jsx(Jotai.Provider, { children: _jsx(ExampleValue, { ...props }) }));
88
- const codeBlock = getByTestId('code-block');
89
- const source = codeBlock.querySelector('pre')?.textContent || '';
90
- expect(source).toContain('<root>');
91
- expect(source).toContain('<name>Test User</name>');
92
- expect(source).toContain('<value>premium</value>');
93
- expect(source).toContain('</root>');
94
- });
95
- it('should not wrap array in root tag for XML', () => {
96
- const arrayValue = [{ item: 'one' }, { item: 'two' }];
97
- const props = {
98
- value: arrayValue,
99
- mimeType: 'application/xml',
100
- onCopyClick: vi.fn(),
101
- };
102
- const { getByTestId } = render(_jsx(Jotai.Provider, { children: _jsx(ExampleValue, { ...props }) }));
103
- const codeBlock = getByTestId('code-block');
104
- const source = codeBlock.querySelector('pre')?.textContent || '';
105
- expect(source).not.toContain('<root>');
106
- expect(source).toContain('<item>one</item>');
107
- expect(source).toContain('<item>two</item>');
108
- });
109
- it('should render pre-built XML string from sampler with attributes (nodeType: attribute)', () => {
110
- const xmlString = '<Artifact catalogId="ART-2024-001">\n <title>Mona Lisa</title>\n</Artifact>';
111
- const props = {
112
- value: xmlString,
113
- mimeType: 'application/xml',
114
- onCopyClick: vi.fn(),
115
- };
116
- const { getByTestId } = render(_jsx(Jotai.Provider, { children: _jsx(ExampleValue, { ...props }) }));
117
- const codeBlock = getByTestId('code-block');
118
- const source = codeBlock.querySelector('pre')?.textContent || '';
119
- expect(source).toContain('catalogId="ART-2024-001"');
120
- expect(source).toContain('<title>Mona Lisa</title>');
121
- });
122
- it('should render pre-built XML string with text nodes (nodeType: text)', () => {
123
- const xmlString = '<Artifact>\n <title>Mona Lisa</title>\nPortrait painting by Leonardo da Vinci</Artifact>';
124
- const props = {
125
- value: xmlString,
126
- mimeType: 'application/xml',
127
- onCopyClick: vi.fn(),
128
- };
129
- const { getByTestId } = render(_jsx(Jotai.Provider, { children: _jsx(ExampleValue, { ...props }) }));
130
- const codeBlock = getByTestId('code-block');
131
- const source = codeBlock.querySelector('pre')?.textContent || '';
132
- expect(source).toContain('Portrait painting by Leonardo da Vinci');
133
- expect(source).toContain('<title>Mona Lisa</title>');
134
- });
135
- it('should render pre-built XML string with CDATA (nodeType: cdata)', () => {
136
- const xmlString = '<Documentation>\n <![CDATA[<html><head><title>Docs</title></head></html>]]>\n</Documentation>';
137
- const props = {
138
- value: xmlString,
139
- mimeType: 'application/xml',
140
- onCopyClick: vi.fn(),
141
- };
142
- const { getByTestId } = render(_jsx(Jotai.Provider, { children: _jsx(ExampleValue, { ...props }) }));
143
- const codeBlock = getByTestId('code-block');
144
- const source = codeBlock.querySelector('pre')?.textContent || '';
145
- expect(source).toContain('<![CDATA[');
146
- expect(source).toContain('<html><head><title>Docs</title></head></html>');
147
- expect(source).toContain(']]>');
148
- });
149
- it('should render pre-built XML string with all nodeTypes combined (sampler output)', () => {
150
- const xmlString = [
151
- '<Artifact catalogId="ART-2024-001" era="Renaissance">',
152
- ' <title>Mona Lisa</title>',
153
- 'Portrait painting by Leonardo da Vinci',
154
- ' <![CDATA[<note>Handle with <b>extreme</b> care</note>]]>',
155
- ' <artists>',
156
- ' <Artist role="painter">',
157
- ' <name>Leonardo da Vinci</name>',
158
- ' </Artist>',
159
- ' </artists>',
160
- '</Artifact>',
161
- ].join('\n');
162
- const props = {
163
- value: xmlString,
164
- mimeType: 'application/xml',
165
- onCopyClick: vi.fn(),
166
- };
167
- const { getByTestId } = render(_jsx(Jotai.Provider, { children: _jsx(ExampleValue, { ...props }) }));
168
- const codeBlock = getByTestId('code-block');
169
- const source = codeBlock.querySelector('pre')?.textContent || '';
170
- expect(source).toContain('catalogId="ART-2024-001"');
171
- expect(source).toContain('era="Renaissance"');
172
- expect(source).toContain('<title>Mona Lisa</title>');
173
- expect(source).toContain('Portrait painting by Leonardo da Vinci');
174
- expect(source).toContain('<![CDATA[<note>Handle with <b>extreme</b> care</note>]]>');
175
- expect(source).not.toContain('internalCode');
176
- expect(source).not.toContain('INT-7742-X');
177
- });
178
- it('should convert JS object to XML with CDATA support via xmlBuilder', () => {
179
- const objectValue = {
180
- Documentation: {
181
- '#cdata': '<html><head><title>Docs</title></head></html>',
182
- },
183
- };
184
- const props = {
185
- value: objectValue,
186
- mimeType: 'application/xml',
187
- onCopyClick: vi.fn(),
188
- };
189
- const { getByTestId } = render(_jsx(Jotai.Provider, { children: _jsx(ExampleValue, { ...props }) }));
190
- const codeBlock = getByTestId('code-block');
191
- const source = codeBlock.querySelector('pre')?.textContent || '';
192
- expect(source).toContain('<![CDATA[');
193
- expect(source).toContain(']]>');
194
- });
195
- });
196
- });
197
- //# sourceMappingURL=ExampleValue.test.js.map
@@ -1,38 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { render } from '@testing-library/react';
3
- import { normalizeOptions, OpenAPIParser } from '../../../services/index.js';
4
- import { getMediaContent, getOperation } from '../../../models/index.js';
5
- import { withTestProviders } from '../../../testProviders.js';
6
- import { PayloadSamples } from '../PayloadSamples.js';
7
- import testDefinition from './fixtures/mediaTypeUrlencoded.json';
8
- describe('PayloadSamples', () => {
9
- let operation;
10
- const options = normalizeOptions({});
11
- const parser = new OpenAPIParser(testDefinition, undefined, options);
12
- test('should renders correctly without example to application/x-www-form-urlencoded', async () => {
13
- operation = getOperation(parser, {
14
- pointer: '#/paths/~1test/get',
15
- pathName: '/test',
16
- httpVerb: 'GET',
17
- pathParameters: [],
18
- pathServers: [],
19
- isWebhook: false,
20
- isAdditionalOperation: false,
21
- ...testDefinition.paths['/test'].get,
22
- }, undefined, options, 'tests');
23
- const props = {
24
- operation,
25
- content: getMediaContent({
26
- parser,
27
- info: testDefinition.paths['/test'].get.requestBody.content,
28
- isRequestType: true,
29
- options,
30
- data: { operation },
31
- }),
32
- onCopyClick: vi.fn(),
33
- };
34
- const { container } = render(withTestProviders(_jsx(PayloadSamples, { ...props }), { definition: parser.definition }));
35
- expect(container).toHaveTextContent(/name=string&status=string/);
36
- });
37
- });
38
- //# sourceMappingURL=PayloadSamples.test.js.map
@@ -1,21 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { render } from '@testing-library/react';
3
- import * as Jotai from 'jotai';
4
- import { Extensions } from '../Extensions.js';
5
- import { normalizeOptions } from '../../../services/index.js';
6
- vi.mock('jotai', async () => ({
7
- ...(await vi.importActual('jotai')),
8
- useAtomValue: vi.fn(),
9
- }));
10
- describe('Components', () => {
11
- describe('Extensions', () => {
12
- it('Extensions label renders correctly', () => {
13
- vi.spyOn(Jotai, 'useAtomValue').mockReturnValue(normalizeOptions({
14
- showExtensions: true,
15
- }));
16
- const { container } = render(_jsx(Extensions, { extensions: { 'x-test': 'Add new pet to the store inventory' } }));
17
- expect(container).toHaveTextContent(/test: Add new pet to the store inventory/);
18
- });
19
- });
20
- });
21
- //# sourceMappingURL=Extensions.test.js.map
@@ -1,52 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { render } from '@testing-library/react';
3
- import { FieldDetail } from '../FieldDetail.js';
4
- describe('FieldDetail', () => {
5
- const wrapper = (label, value) => render(_jsx(FieldDetail, { label: label, value: value }));
6
- it('should render with DefaultValue component', () => {
7
- const { getByText } = wrapper('Default', 'value');
8
- expect(getByText('"value"')).toBeInTheDocument();
9
- expect(getByText('Default')).toBeInTheDocument();
10
- });
11
- it('should render with ExampleValue component', () => {
12
- const { getByText } = wrapper('Example:', 'value');
13
- expect(getByText('"value"')).toBeInTheDocument();
14
- expect(getByText('Example:')).toBeInTheDocument();
15
- });
16
- it('should render FieldValueLabel in all other cases', () => {
17
- const { getByText } = wrapper('Deprecated', 'value');
18
- expect(getByText('"value"')).toBeInTheDocument();
19
- expect(getByText('Deprecated')).toBeInTheDocument();
20
- });
21
- describe('example type with structured values', () => {
22
- const objectValue = {
23
- name: 'John Alfred Smith',
24
- street: '123 Main Street',
25
- city: 'San Francisco',
26
- };
27
- it('should render object example pretty-printed with JSON highlighting', () => {
28
- const { getByTestId, getByText } = render(_jsx(FieldDetail, { label: "Example:", value: objectValue, type: "example" }));
29
- expect(getByText('Example:')).toBeInTheDocument();
30
- const viewer = getByTestId('json-viewer');
31
- // pretty-printed: keys and values are separate tokens on multiple lines,
32
- // not a single-line JSON.stringify blob
33
- expect(viewer.textContent).toContain('"name"');
34
- expect(viewer.textContent).toContain('"John Alfred Smith"');
35
- expect(viewer.textContent).toContain('\n');
36
- // syntax highlighting: token spans styled by the code theme
37
- expect(viewer.querySelector('.token.string')).not.toBeNull();
38
- });
39
- it('should render array example pretty-printed with JSON highlighting', () => {
40
- const { getByTestId } = render(_jsx(FieldDetail, { label: "Example:", value: ['79f943e212cce7de21c054a8'], type: "example" }));
41
- const viewer = getByTestId('json-viewer');
42
- expect(viewer.textContent).toContain('"79f943e212cce7de21c054a8"');
43
- expect(viewer.querySelector('.token.string')).not.toBeNull();
44
- });
45
- it('should keep scalar example values inline without JSON viewer', () => {
46
- const { getByText, queryByTestId } = render(_jsx(FieldDetail, { label: "Example:", value: "HRIS-27", type: "example" }));
47
- expect(getByText('"HRIS-27"')).toBeInTheDocument();
48
- expect(queryByTestId('json-viewer')).toBeNull();
49
- });
50
- });
51
- });
52
- //# sourceMappingURL=FieldDetail.test.js.map