@redocly/openapi-docs 3.24.0-next.9 → 3.24.1
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.
- package/dist/{redocly-openapi-docs.min.AiChatProvider-DcsGB2gP.js → redocly-openapi-docs.min.AiChatProvider-j-VDfFJ9.js} +3 -3
- package/dist/{redocly-openapi-docs.min.AiChatSqliteDBStorage-wCZA4usG.js → redocly-openapi-docs.min.AiChatSqliteDBStorage-BBRBmffc.js} +1 -1
- package/dist/{redocly-openapi-docs.min.AiPanel-jo7fqtSt.js → redocly-openapi-docs.min.AiPanel-DTzHqAiI.js} +116 -116
- package/dist/redocly-openapi-docs.min.FileWatcher-DDoyaS7A.js +1 -0
- package/dist/redocly-openapi-docs.min.Observable-D6wKbFwB.js +1 -0
- package/dist/redocly-openapi-docs.min.SemanticSearchService-DNFOPBZK.js +1 -0
- package/dist/{redocly-openapi-docs.min.SqliteDBStorage-B_f6WR8o.js → redocly-openapi-docs.min.SqliteDBStorage-Dy40Vq04.js} +1 -1
- package/dist/redocly-openapi-docs.min.TauriFileSystemAdapter-CpViFqJQ.js +1 -0
- package/dist/redocly-openapi-docs.min.TauriRootStorage-TCUrp2uB.js +1 -0
- package/dist/redocly-openapi-docs.min.ai-chat-mappers-CmX-8902.js +1 -0
- package/dist/redocly-openapi-docs.min.core-BYyFOtMX.js +1 -0
- package/dist/redocly-openapi-docs.min.external-resolver-BkceRyB4.js +2 -0
- package/dist/redocly-openapi-docs.min.index-BCcol5vU.js +1 -0
- package/dist/redocly-openapi-docs.min.index-C6uU_v-b.js +1 -0
- package/dist/redocly-openapi-docs.min.index-CmXZfuiZ.js +7730 -0
- package/dist/redocly-openapi-docs.min.index-DVWw0ICA.js +1 -0
- package/dist/redocly-openapi-docs.min.index-YnvLQkG_.js +1 -0
- package/dist/redocly-openapi-docs.min.index-xl_tBaHD.js +1 -0
- package/dist/redocly-openapi-docs.min.js +1 -1
- package/dist/{redocly-openapi-docs.min.lint-C-zlwxhp.js → redocly-openapi-docs.min.lint-2YpbCz3r.js} +69 -69
- package/dist/{redocly-openapi-docs.min.lint-graphql-qEh9cZHx.js → redocly-openapi-docs.min.lint-graphql-Bgfcu2tP.js} +1 -1
- package/dist/redocly-openapi-docs.min.periodic-revalidation-Dsp-n7ui.js +1 -0
- package/dist/redocly-openapi-docs.min.promise-map-limit-Db_42GvV.js +1 -0
- package/dist/{redocly-openapi-docs.min.respect-run-hfNPYQ9x.js → redocly-openapi-docs.min.respect-run-Ct8taisL.js} +1 -1
- package/dist/redocly-openapi-docs.min.standalone-BPCdJgtH.js +11995 -0
- package/dist/redocly-openapi-docs.min.tauri-path-CmqBCxGb.js +1 -0
- package/dist/{redocly-openapi-docs.min.useAiChatQueries-DgSsCKMW.js → redocly-openapi-docs.min.useAiChatQueries-t8oy8jik.js} +80 -80
- package/lib/components/ApiInfo/__tests__/ApiInfo.test.d.ts +1 -0
- package/lib/components/ApiInfo/__tests__/ApiInfo.test.js +46 -0
- package/lib/components/Callbacks/CallbackOperation.js +1 -1
- package/lib/components/Callbacks/__tests__/Callbacks.test.d.ts +1 -0
- package/lib/components/Callbacks/__tests__/Callbacks.test.js +46 -0
- package/lib/components/Content/__tests__/useAutoScroll.test.d.ts +1 -0
- package/lib/components/Content/__tests__/useAutoScroll.test.js +88 -0
- package/lib/components/Content/useAutoScroll.js +1 -1
- package/lib/components/ContentItem/__tests__/useIsExpanded.test.d.ts +1 -0
- package/lib/components/ContentItem/__tests__/useIsExpanded.test.js +123 -0
- package/lib/components/ContentItem/useIsExpanded.js +1 -1
- package/lib/components/ContentItems/ContentItems.js +1 -1
- package/lib/components/ContentItems/VirtualList.js +1 -1
- package/lib/components/ContentItems/__tests__/Items.test.d.ts +1 -0
- package/lib/components/ContentItems/__tests__/Items.test.js +66 -0
- package/lib/components/ContentItems/__tests__/VirtualList.test.d.ts +1 -0
- package/lib/components/ContentItems/__tests__/VirtualList.test.js +135 -0
- package/lib/components/ContentItems/useScrollOnRender.js +1 -1
- package/lib/components/Discriminator/__tests__/DiscriminatorDropdown.test.d.ts +1 -0
- package/lib/components/Discriminator/__tests__/DiscriminatorDropdown.test.js +63 -0
- package/lib/components/Download/__tests__/DownloadSpecification.test.d.ts +1 -0
- package/lib/components/Download/__tests__/DownloadSpecification.test.js +52 -0
- package/lib/components/ExpandAllButton/__tests__/ExpandAllButton.test.d.ts +1 -0
- package/lib/components/ExpandAllButton/__tests__/ExpandAllButton.test.js +60 -0
- package/lib/components/ExpandAllButton/__tests__/helpers.test.d.ts +1 -0
- package/lib/components/ExpandAllButton/__tests__/helpers.test.js +133 -0
- package/lib/components/Language/__tests__/LanguageDropdown.test.d.ts +1 -0
- package/lib/components/Language/__tests__/LanguageDropdown.test.js +23 -0
- package/lib/components/Markdown/__tests__/Markdown.test.d.ts +1 -0
- package/lib/components/Markdown/__tests__/Markdown.test.js +34 -0
- package/lib/components/McpOverview/__tests__/McpOverview.test.d.ts +1 -0
- package/lib/components/McpOverview/__tests__/McpOverview.test.js +66 -0
- package/lib/components/McpTool/__tests__/McpPrompt.test.d.ts +1 -0
- package/lib/components/McpTool/__tests__/McpPrompt.test.js +57 -0
- package/lib/components/McpTool/__tests__/McpResource.test.d.ts +1 -0
- package/lib/components/McpTool/__tests__/McpResource.test.js +81 -0
- package/lib/components/McpTool/__tests__/McpTool.test.d.ts +1 -0
- package/lib/components/McpTool/__tests__/McpTool.test.js +82 -0
- package/lib/components/MediaTypeSwitch/__tests__/MediaTypesSwitch.test.d.ts +1 -0
- package/lib/components/MediaTypeSwitch/__tests__/MediaTypesSwitch.test.js +79 -0
- package/lib/components/OperationItem/__tests__/OperationItem.test.d.ts +1 -0
- package/lib/components/OperationItem/__tests__/OperationItem.test.js +70 -0
- package/lib/components/OperationItem/__tests__/__mocks__/mock-intersection-observer.d.ts +16 -0
- package/lib/components/OperationItem/__tests__/__mocks__/mock-intersection-observer.js +42 -0
- package/lib/components/Overview/__tests__/Overview.test.d.ts +1 -0
- package/lib/components/Overview/__tests__/Overview.test.js +59 -0
- package/lib/components/PayloadSamples/__tests__/Example.test.d.ts +1 -0
- package/lib/components/PayloadSamples/__tests__/Example.test.js +36 -0
- package/lib/components/PayloadSamples/__tests__/ExampleValue.test.d.ts +1 -0
- package/lib/components/PayloadSamples/__tests__/ExampleValue.test.js +197 -0
- package/lib/components/PayloadSamples/__tests__/PayloadSamples.test.d.ts +1 -0
- package/lib/components/PayloadSamples/__tests__/PayloadSamples.test.js +38 -0
- package/lib/components/PropertyDetails/__tests__/Extensions.test.d.ts +1 -0
- package/lib/components/PropertyDetails/__tests__/Extensions.test.js +21 -0
- package/lib/components/PropertyDetails/__tests__/FieldDetail.test.d.ts +1 -0
- package/lib/components/PropertyDetails/__tests__/FieldDetail.test.js +52 -0
- package/lib/components/PropertyDetails/__tests__/FieldDetails.test.d.ts +1 -0
- package/lib/components/PropertyDetails/__tests__/FieldDetails.test.js +191 -0
- package/lib/components/PropertyDetails/__tests__/PropertyDetails.test.d.ts +1 -0
- package/lib/components/PropertyDetails/__tests__/PropertyDetails.test.js +365 -0
- package/lib/components/PropertyDetails/__tests__/cycleColorsByLevel.test.d.ts +1 -0
- package/lib/components/PropertyDetails/__tests__/cycleColorsByLevel.test.js +23 -0
- package/lib/components/RedoclyOpenAPIDocs/__tests__/AppProvider.test.d.ts +1 -0
- package/lib/components/RedoclyOpenAPIDocs/__tests__/AppProvider.test.js +16 -0
- package/lib/components/RedoclyOpenAPIDocs/__tests__/RedoclyOpenAPIDocs.test.d.ts +1 -0
- package/lib/components/RedoclyOpenAPIDocs/__tests__/RedoclyOpenAPIDocs.test.js +104 -0
- package/lib/components/RenderHook/__tests__/RenderHook.test.d.ts +1 -0
- package/lib/components/RenderHook/__tests__/RenderHook.test.js +15 -0
- package/lib/components/Replay/__tests__/utils.test.d.ts +1 -0
- package/lib/components/Replay/__tests__/utils.test.js +526 -0
- package/lib/components/Request/__tests__/RequestDetails.test.d.ts +1 -0
- package/lib/components/Request/__tests__/RequestDetails.test.js +98 -0
- package/lib/components/RequestSamples/__tests__/Example.test.d.ts +1 -0
- package/lib/components/RequestSamples/__tests__/Example.test.js +384 -0
- package/lib/components/RequestSamples/__tests__/RequestSamples.test.d.ts +1 -0
- package/lib/components/RequestSamples/__tests__/RequestSamples.test.js +226 -0
- package/lib/components/RequestSamples/__tests__/useCodeSamples.test.d.ts +1 -0
- package/lib/components/RequestSamples/__tests__/useCodeSamples.test.js +64 -0
- package/lib/components/ResponseSamples/__tests__/ResponseSamples.test.d.ts +1 -0
- package/lib/components/ResponseSamples/__tests__/ResponseSamples.test.js +29 -0
- package/lib/components/Responses/OperationResponseList.js +1 -1
- package/lib/components/Responses/__tests__/OperationResponseList.test.d.ts +1 -0
- package/lib/components/Responses/__tests__/OperationResponseList.test.js +89 -0
- package/lib/components/Responses/__tests__/ResponseDetails.test.d.ts +1 -0
- package/lib/components/Responses/__tests__/ResponseDetails.test.js +111 -0
- package/lib/components/Responses/__tests__/ResponsesHeaders.test.d.ts +1 -0
- package/lib/components/Responses/__tests__/ResponsesHeaders.test.js +26 -0
- package/lib/components/Schema/Schema.js +1 -1
- package/lib/components/Schema/SubSchema.js +1 -1
- package/lib/components/Schema/__tests__/ArraySchema.test.d.ts +1 -0
- package/lib/components/Schema/__tests__/ArraySchema.test.js +93 -0
- package/lib/components/Schema/__tests__/ObjectSchema.test.d.ts +1 -0
- package/lib/components/Schema/__tests__/ObjectSchema.test.js +115 -0
- package/lib/components/Schema/__tests__/OneOfSchema.test.d.ts +1 -0
- package/lib/components/Schema/__tests__/OneOfSchema.test.js +33 -0
- package/lib/components/Schema/__tests__/Schema.test.d.ts +1 -0
- package/lib/components/Schema/__tests__/Schema.test.js +67 -0
- package/lib/components/Schema/__tests__/useOneOfLocationIdx.test.d.ts +1 -0
- package/lib/components/Schema/__tests__/useOneOfLocationIdx.test.js +22 -0
- package/lib/components/Schema/useOneOfLocationIdx.js +1 -1
- package/lib/components/SchemaCatalogLink/__tests__/SchemaCatalogLink.test.d.ts +1 -0
- package/lib/components/SchemaCatalogLink/__tests__/SchemaCatalogLink.test.js +95 -0
- package/lib/components/Security/__tests__/Security.test.d.ts +1 -0
- package/lib/components/Security/__tests__/Security.test.js +38 -0
- package/lib/components/Security/__tests__/SecurityButton.test.d.ts +1 -0
- package/lib/components/Security/__tests__/SecurityButton.test.js +92 -0
- package/lib/components/Security/__tests__/SecurityModal.test.d.ts +1 -0
- package/lib/components/Security/__tests__/SecurityModal.test.js +172 -0
- package/lib/components/ServerList/__tests__/ServerList.test.d.ts +1 -0
- package/lib/components/ServerList/__tests__/ServerList.test.js +83 -0
- package/lib/components/SideMenu/hooks/useMenuItems.js +1 -1
- package/lib/components/StickySidebar/StickyResponsiveSidebar.js +1 -1
- package/lib/components/Tabs/__tests__/Tabs.test.d.ts +1 -0
- package/lib/components/Tabs/__tests__/Tabs.test.js +27 -0
- package/lib/components/TagItem/OperationsNavigation.js +1 -1
- package/lib/components/TagItem/TagItem.js +1 -1
- package/lib/components/ViewNested/__tests__/ViewNested.test.d.ts +1 -0
- package/lib/components/ViewNested/__tests__/ViewNested.test.js +42 -0
- package/lib/components/__tests__/Samples/ExampleSwitch.test.d.ts +1 -0
- package/lib/components/__tests__/Samples/ExampleSwitch.test.js +45 -0
- package/lib/components/__tests__/Samples/use-example-key.test.d.ts +1 -0
- package/lib/components/__tests__/Samples/use-example-key.test.js +28 -0
- package/lib/components/__tests__/common/ClearButton.test.d.ts +1 -0
- package/lib/components/__tests__/common/ClearButton.test.js +18 -0
- package/lib/components/__tests__/common/Dropdown.test.d.ts +1 -0
- package/lib/components/__tests__/common/Dropdown.test.js +52 -0
- package/lib/components/__tests__/mocks/examples.d.ts +4 -0
- package/lib/components/__tests__/mocks/examples.js +115 -0
- package/lib/components/common/LinkToField.js +1 -1
- package/lib/components/common/__tests__/Dropdown.test.d.ts +1 -0
- package/lib/components/common/__tests__/Dropdown.test.js +129 -0
- package/lib/components/common/__tests__/LinkToField.test.d.ts +1 -0
- package/lib/components/common/__tests__/LinkToField.test.js +39 -0
- package/lib/components/common/linkify.js +1 -1
- package/lib/hooks/useRouter.js +1 -1
- package/lib/hooks/useUppercase2LowercaseRedirect.js +1 -1
- package/lib/jotai/__tests__/app.test.d.ts +1 -0
- package/lib/jotai/__tests__/app.test.js +53 -0
- package/lib/models/__tests__/Callback.test.d.ts +1 -0
- package/lib/models/__tests__/Callback.test.js +15 -0
- package/lib/models/__tests__/FieldModel.test.d.ts +1 -0
- package/lib/models/__tests__/FieldModel.test.js +117 -0
- package/lib/models/__tests__/MediaContent.test.d.ts +1 -0
- package/lib/models/__tests__/MediaContent.test.js +105 -0
- package/lib/models/__tests__/Operation.test.d.ts +1 -0
- package/lib/models/__tests__/Operation.test.js +459 -0
- package/lib/models/__tests__/Response.test.d.ts +1 -0
- package/lib/models/__tests__/Response.test.js +221 -0
- package/lib/models/__tests__/Schema.circular.test.d.ts +1 -0
- package/lib/models/__tests__/Schema.circular.test.js +694 -0
- package/lib/models/__tests__/Schema.test.d.ts +1 -0
- package/lib/models/__tests__/Schema.test.js +1395 -0
- package/lib/models/__tests__/example.test.d.ts +1 -0
- package/lib/models/__tests__/example.test.js +90 -0
- package/lib/models/__tests__/group.test.d.ts +1 -0
- package/lib/models/__tests__/group.test.js +52 -0
- package/lib/models/__tests__/helpers.d.ts +5 -0
- package/lib/models/__tests__/helpers.js +62 -0
- package/lib/models/__tests__/request.test.d.ts +1 -0
- package/lib/models/__tests__/request.test.js +119 -0
- package/lib/services/__tests__/OpenAPIParser.test.d.ts +1 -0
- package/lib/services/__tests__/OpenAPIParser.test.js +80 -0
- package/lib/services/__tests__/check.test.d.ts +1 -0
- package/lib/services/__tests__/check.test.js +22 -0
- package/lib/services/__tests__/utils.test.d.ts +1 -0
- package/lib/services/__tests__/utils.test.js +42 -0
- package/lib/services/code-samples/__tests__/apply-environments.test.d.ts +1 -0
- package/lib/services/code-samples/__tests__/apply-environments.test.js +64 -0
- package/lib/services/code-samples/__tests__/build-code-samples.test.d.ts +1 -0
- package/lib/services/code-samples/__tests__/build-code-samples.test.js +70 -0
- package/lib/services/code-samples/__tests__/convertSampleToString.test.d.ts +1 -0
- package/lib/services/code-samples/__tests__/convertSampleToString.test.js +116 -0
- package/lib/services/code-samples/__tests__/generator-data-value.test.d.ts +1 -0
- package/lib/services/code-samples/__tests__/generator-data-value.test.js +277 -0
- package/lib/services/code-samples/__tests__/generator-serialized-value.test.d.ts +1 -0
- package/lib/services/code-samples/__tests__/generator-serialized-value.test.js +258 -0
- package/lib/services/code-samples/__tests__/generator-value.test.d.ts +1 -0
- package/lib/services/code-samples/__tests__/generator-value.test.js +273 -0
- package/lib/services/code-samples/__tests__/generator.test.d.ts +249 -0
- package/lib/services/code-samples/__tests__/generator.test.js +1201 -0
- package/lib/services/code-samples/__tests__/get-example-value-by-mime-type.test.d.ts +1 -0
- package/lib/services/code-samples/__tests__/get-example-value-by-mime-type.test.js +31 -0
- package/lib/services/code-samples/httpsnippet/__tests__/device-authorization.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/__tests__/device-authorization.test.js +222 -0
- package/lib/services/code-samples/httpsnippet/helpers/__tests__/code-helpers.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/helpers/__tests__/code-helpers.test.js +129 -0
- package/lib/services/code-samples/httpsnippet/helpers/__tests__/string-utility.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/helpers/__tests__/string-utility.test.js +49 -0
- package/lib/services/code-samples/httpsnippet/targets/csharp/__tests__/httpclient.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/csharp/__tests__/httpclient.test.js +172 -0
- package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/__tests__/httpclient.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/__tests__/httpclient.test.js +172 -0
- package/lib/services/code-samples/httpsnippet/targets/go/__tests__/native.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/go/__tests__/native.test.js +130 -0
- package/lib/services/code-samples/httpsnippet/targets/java/__tests__/httpclient.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/java/__tests__/httpclient.test.js +191 -0
- package/lib/services/code-samples/httpsnippet/targets/java8/__tests__/apachehttp.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/java8/__tests__/apachehttp.test.js +172 -0
- package/lib/services/code-samples/httpsnippet/targets/javascript/__tests__/fetch.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/javascript/__tests__/fetch.test.js +85 -0
- package/lib/services/code-samples/httpsnippet/targets/node/__tests__/fetch.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/node/__tests__/fetch.test.js +85 -0
- package/lib/services/code-samples/httpsnippet/targets/php/__tests__/curl.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/php/__tests__/curl.test.js +126 -0
- package/lib/services/code-samples/httpsnippet/targets/python/__tests__/requests.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/python/__tests__/requests.test.js +105 -0
- package/lib/services/code-samples/httpsnippet/targets/r/__tests__/httr.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/r/__tests__/httr.test.js +126 -0
- package/lib/services/code-samples/httpsnippet/targets/ruby/__tests__/native.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/ruby/__tests__/native.test.js +129 -0
- package/lib/services/code-samples/httpsnippet/targets/shell/__tests__/curl.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/shell/__tests__/curl.test.js +129 -0
- package/lib/services/config-options/__tests__/helpers.test.d.ts +1 -0
- package/lib/services/config-options/__tests__/helpers.test.js +234 -0
- package/lib/services/history/__tests__/helpers.test.d.ts +1 -0
- package/lib/services/history/__tests__/helpers.test.js +19 -0
- package/lib/services/menu/__tests__/buildNestedTagsItems.test.d.ts +1 -0
- package/lib/services/menu/__tests__/buildNestedTagsItems.test.js +109 -0
- package/lib/services/menu/__tests__/builder.test.d.ts +1 -0
- package/lib/services/menu/__tests__/builder.test.js +307 -0
- package/lib/services/menu/__tests__/operation.test.d.ts +1 -0
- package/lib/services/menu/__tests__/operation.test.js +240 -0
- package/lib/services/menu/__tests__/tags.test.d.ts +1 -0
- package/lib/services/menu/__tests__/tags.test.js +71 -0
- package/lib/telemetry/RedocTelemetry.js +31 -1
- package/lib/telemetry/__tests__/RedocTelemetry.test.d.ts +1 -0
- package/lib/telemetry/__tests__/RedocTelemetry.test.js +107 -0
- package/lib/testProviders.d.ts +6 -0
- package/lib/testProviders.js +14 -0
- package/lib/utils/__tests__/areArraysEqual.test.d.ts +1 -0
- package/lib/utils/__tests__/areArraysEqual.test.js +33 -0
- package/lib/utils/__tests__/argValuesHelpers.d.ts +1 -0
- package/lib/utils/__tests__/argValuesHelpers.js +56 -0
- package/lib/utils/__tests__/calculateMaxLength.test.d.ts +1 -0
- package/lib/utils/__tests__/calculateMaxLength.test.js +119 -0
- package/lib/utils/__tests__/configure-helpers.test.d.ts +1 -0
- package/lib/utils/__tests__/configure-helpers.test.js +356 -0
- package/lib/utils/__tests__/convertSwagger2OpenAPI.test.d.ts +1 -0
- package/lib/utils/__tests__/convertSwagger2OpenAPI.test.js +392 -0
- package/lib/utils/__tests__/debounce.test.d.ts +1 -0
- package/lib/utils/__tests__/debounce.test.js +54 -0
- package/lib/utils/__tests__/debug.test.d.ts +1 -0
- package/lib/utils/__tests__/debug.test.js +23 -0
- package/lib/utils/__tests__/dom.test.d.ts +1 -0
- package/lib/utils/__tests__/dom.test.js +108 -0
- package/lib/utils/__tests__/getBreadcrumbs.test.d.ts +1 -0
- package/lib/utils/__tests__/getBreadcrumbs.test.js +98 -0
- package/lib/utils/__tests__/hasNestedFields.test.d.ts +1 -0
- package/lib/utils/__tests__/hasNestedFields.test.js +147 -0
- package/lib/utils/__tests__/helpers.test.d.ts +1 -0
- package/lib/utils/__tests__/helpers.test.js +174 -0
- package/lib/utils/__tests__/isMobile.test.d.ts +1 -0
- package/lib/utils/__tests__/isMobile.test.js +28 -0
- package/lib/utils/__tests__/loadAndBundleSpec.test.d.ts +1 -0
- package/lib/utils/__tests__/loadAndBundleSpec.test.js +22 -0
- package/lib/utils/__tests__/local-storage.test.d.ts +1 -0
- package/lib/utils/__tests__/local-storage.test.js +48 -0
- package/lib/utils/__tests__/object.test.d.ts +1 -0
- package/lib/utils/__tests__/object.test.js +45 -0
- package/lib/utils/__tests__/openapi.test.d.ts +1 -0
- package/lib/utils/__tests__/openapi.test.js +1378 -0
- package/lib/utils/__tests__/path.test.d.ts +1 -0
- package/lib/utils/__tests__/path.test.js +16 -0
- package/lib/utils/__tests__/queryString.test.d.ts +1 -0
- package/lib/utils/__tests__/queryString.test.js +60 -0
- package/lib/utils/__tests__/replaceVariables.test.d.ts +1 -0
- package/lib/utils/__tests__/replaceVariables.test.js +46 -0
- package/lib/utils/__tests__/simplifyAstStructure.test.d.ts +1 -0
- package/lib/utils/__tests__/simplifyAstStructure.test.js +26 -0
- package/lib/utils/__tests__/sort.test.d.ts +1 -0
- package/lib/utils/__tests__/sort.test.js +16 -0
- package/lib/utils/__tests__/string.test.d.ts +1 -0
- package/lib/utils/__tests__/string.test.js +16 -0
- package/lib/utils/__tests__/theme-helpers.test.d.ts +1 -0
- package/lib/utils/__tests__/theme-helpers.test.js +24 -0
- package/lib/utils/__tests__/url.test.d.ts +1 -0
- package/lib/utils/__tests__/url.test.js +134 -0
- package/lib/utils/path.d.ts +1 -1
- package/package.json +12 -12
- package/dist/redocly-openapi-docs.min.ai-chat-mappers-MY79QAeW.js +0 -1
- package/dist/redocly-openapi-docs.min.external-resolver-3KMJv7SC.js +0 -2
- package/dist/redocly-openapi-docs.min.index-BYVMr_la.js +0 -1
- package/dist/redocly-openapi-docs.min.index-CsqzTi3Z.js +0 -7586
- package/dist/redocly-openapi-docs.min.index-D8F7x0S6.js +0 -1
- package/dist/redocly-openapi-docs.min.index-qqKTpI_q.js +0 -1
- package/dist/redocly-openapi-docs.min.standalone-Ci6886Cr.js +0 -12114
- package/dist/redocly-openapi-docs.min.tauri-path-Bs1-AQjc.js +0 -1
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { processOperation } from '../tags.js';
|
|
2
|
+
describe('processOperation', () => {
|
|
3
|
+
let parser;
|
|
4
|
+
let tagsMap;
|
|
5
|
+
beforeEach(() => {
|
|
6
|
+
parser = {
|
|
7
|
+
definition: {},
|
|
8
|
+
deref: vi.fn().mockReturnValue({ resolved: {} }),
|
|
9
|
+
};
|
|
10
|
+
tagsMap = {};
|
|
11
|
+
});
|
|
12
|
+
it('adds operation to existing tag', () => {
|
|
13
|
+
const operationInfo = { summary: 'Test op', tags: ['tag1'] };
|
|
14
|
+
tagsMap['tag1'] = { name: 'tag1', operations: [] };
|
|
15
|
+
processOperation(parser, 'get', operationInfo, '/path', {}, tagsMap);
|
|
16
|
+
expect(tagsMap['tag1'].operations).toHaveLength(1);
|
|
17
|
+
expect(tagsMap['tag1'].operations[0].summary).toBe('Test op');
|
|
18
|
+
});
|
|
19
|
+
it('creates tag if it does not exist', () => {
|
|
20
|
+
const operationInfo = { summary: 'New op', tags: ['newTag'] };
|
|
21
|
+
processOperation(parser, 'post', operationInfo, '/path', {}, tagsMap);
|
|
22
|
+
expect(tagsMap['newTag']).toBeDefined();
|
|
23
|
+
expect(tagsMap['newTag'].operations[0].summary).toBe('New op');
|
|
24
|
+
});
|
|
25
|
+
it('assigns empty tag if operation has no tags', () => {
|
|
26
|
+
const operationInfo = { summary: 'No tag op' };
|
|
27
|
+
processOperation(parser, 'put', operationInfo, '/path', {}, tagsMap);
|
|
28
|
+
expect(tagsMap['']).toBeDefined();
|
|
29
|
+
expect(tagsMap[''].operations[0].httpVerb).toBe('put');
|
|
30
|
+
});
|
|
31
|
+
it('assigns default webhook tag if isWebhook is true and no tags', () => {
|
|
32
|
+
const operationInfo = { summary: 'Webhook op' };
|
|
33
|
+
processOperation(parser, 'post', operationInfo, '/webhook', {}, tagsMap, true);
|
|
34
|
+
expect(tagsMap['webhooks']).toBeDefined();
|
|
35
|
+
expect(tagsMap['webhooks'].operations[0].isWebhook).toBe(true);
|
|
36
|
+
});
|
|
37
|
+
it('skips operations with x-traitTag', () => {
|
|
38
|
+
const operationInfo = { summary: 'Trait op', tags: ['traitTag'] };
|
|
39
|
+
tagsMap['traitTag'] = { name: 'traitTag', operations: [], 'x-traitTag': true };
|
|
40
|
+
processOperation(parser, 'get', operationInfo, '/path', {}, tagsMap);
|
|
41
|
+
expect(tagsMap['traitTag'].operations).toHaveLength(0);
|
|
42
|
+
});
|
|
43
|
+
it('processes additionalOperations correctly', () => {
|
|
44
|
+
const path = {
|
|
45
|
+
additionalOperations: {
|
|
46
|
+
test: { summary: 'Additional op', tags: ['tag2'] },
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
tagsMap['tag2'] = { name: 'tag2', operations: [] };
|
|
50
|
+
processOperation(parser, 'test', path.additionalOperations.test, '/path', path, tagsMap, false, true);
|
|
51
|
+
expect(tagsMap['tag2'].operations).toHaveLength(1);
|
|
52
|
+
expect(tagsMap['tag2'].operations[0].isAdditionalOperation).toBe(true);
|
|
53
|
+
});
|
|
54
|
+
it('assigns query tag if operation is x-query', () => {
|
|
55
|
+
const operationInfo = { summary: 'Query op', tags: ['query'] };
|
|
56
|
+
const path = { 'x-query': operationInfo };
|
|
57
|
+
tagsMap['query'] = { name: 'query', operations: [] };
|
|
58
|
+
processOperation(parser, 'x-query', operationInfo, '/path', path, tagsMap);
|
|
59
|
+
expect(tagsMap['query'].operations).toHaveLength(1);
|
|
60
|
+
expect(tagsMap['query'].operations[0].httpVerb).toBe('query');
|
|
61
|
+
});
|
|
62
|
+
it('keeps httpVerb as query if operation name is query (OpenAPI 3.2.0)', () => {
|
|
63
|
+
const operationInfo = { summary: 'Query op', tags: ['query'] };
|
|
64
|
+
const path = { query: operationInfo };
|
|
65
|
+
tagsMap['query'] = { name: 'query', operations: [] };
|
|
66
|
+
processOperation(parser, 'query', operationInfo, '/path', path, tagsMap);
|
|
67
|
+
expect(tagsMap['query'].operations).toHaveLength(1);
|
|
68
|
+
expect(tagsMap['query'].operations[0].httpVerb).toBe('query');
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
//# sourceMappingURL=tags.test.js.map
|
|
@@ -1 +1,31 @@
|
|
|
1
|
-
import{Telemetry
|
|
1
|
+
import { Telemetry } from '@redocly/redoc-opentelemetry';
|
|
2
|
+
import pkg from '../../package.json' with { type: 'json' };
|
|
3
|
+
const OTEL_TRACES_URL = 'https://otel.cloud.redocly.com/v1/traces';
|
|
4
|
+
export class RedocTelemetry extends Telemetry {
|
|
5
|
+
specType;
|
|
6
|
+
constructor(config) {
|
|
7
|
+
super();
|
|
8
|
+
this.specType = config.specType;
|
|
9
|
+
this.init({
|
|
10
|
+
otel: {
|
|
11
|
+
isProd: process.env.NODE_ENV === 'production' || process.env.ENABLE_LOCAL_TELEMETRY === 'true',
|
|
12
|
+
serviceVersion: config.serviceVersion || `${pkg.name}@${pkg.version}`,
|
|
13
|
+
version: '1.0.0',
|
|
14
|
+
collectorTraceUrl: config.collectorUrl || OTEL_TRACES_URL,
|
|
15
|
+
serviceName: config.serviceName || 'redoc-ce',
|
|
16
|
+
tracerName: 'client-telemetry',
|
|
17
|
+
},
|
|
18
|
+
disabled: config.disabled || false,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
// TODO: remove this once we have a proper way to enrich the data
|
|
22
|
+
send(event, data) {
|
|
23
|
+
if (data && Array.isArray(data) && data.length > 0) {
|
|
24
|
+
data = data.map((item) => item && typeof item === 'object' ? { ...item, specType: this.specType } : item);
|
|
25
|
+
}
|
|
26
|
+
super.send(event, data, {
|
|
27
|
+
env: process.env.NODE_ENV,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=RedocTelemetry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
const initMock = vi.fn();
|
|
3
|
+
const sendMock = vi.fn();
|
|
4
|
+
vi.mock('@redocly/redoc-opentelemetry', () => ({
|
|
5
|
+
Telemetry: class Telemetry {
|
|
6
|
+
init(config) {
|
|
7
|
+
initMock(config);
|
|
8
|
+
}
|
|
9
|
+
send(event, data) {
|
|
10
|
+
sendMock(event, data);
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
}));
|
|
14
|
+
import { RedocTelemetry } from '../RedocTelemetry.js';
|
|
15
|
+
describe('RedocTelemetry', () => {
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
vi.clearAllMocks();
|
|
18
|
+
});
|
|
19
|
+
describe('constructor', () => {
|
|
20
|
+
it('calls init with default collector URL and service name when not provided', () => {
|
|
21
|
+
new RedocTelemetry({
|
|
22
|
+
specType: 'openapi',
|
|
23
|
+
serviceVersion: '1.0.0',
|
|
24
|
+
});
|
|
25
|
+
expect(initMock).toHaveBeenCalledTimes(1);
|
|
26
|
+
expect(initMock).toHaveBeenCalledWith(expect.objectContaining({
|
|
27
|
+
otel: expect.objectContaining({
|
|
28
|
+
collectorTraceUrl: 'https://otel.cloud.redocly.com/v1/traces',
|
|
29
|
+
serviceName: 'redoc-ce',
|
|
30
|
+
serviceVersion: '1.0.0',
|
|
31
|
+
}),
|
|
32
|
+
}));
|
|
33
|
+
});
|
|
34
|
+
it('calls init with custom collectorUrl and serviceName when provided', () => {
|
|
35
|
+
new RedocTelemetry({
|
|
36
|
+
specType: 'asyncapi',
|
|
37
|
+
serviceVersion: '2.0.0',
|
|
38
|
+
collectorUrl: 'https://custom.example.com/v1/traces',
|
|
39
|
+
serviceName: 'custom-service',
|
|
40
|
+
});
|
|
41
|
+
expect(initMock).toHaveBeenCalledWith(expect.objectContaining({
|
|
42
|
+
otel: expect.objectContaining({
|
|
43
|
+
collectorTraceUrl: 'https://custom.example.com/v1/traces',
|
|
44
|
+
serviceName: 'custom-service',
|
|
45
|
+
serviceVersion: '2.0.0',
|
|
46
|
+
}),
|
|
47
|
+
}));
|
|
48
|
+
});
|
|
49
|
+
it('calls init with disabled when config.disabled is true', () => {
|
|
50
|
+
new RedocTelemetry({
|
|
51
|
+
specType: 'graphql',
|
|
52
|
+
serviceVersion: '1.0.0',
|
|
53
|
+
disabled: true,
|
|
54
|
+
});
|
|
55
|
+
expect(initMock).toHaveBeenCalledWith(expect.objectContaining({
|
|
56
|
+
disabled: true,
|
|
57
|
+
}));
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
describe('send', () => {
|
|
61
|
+
it('calls super.send with event and undefined when data is omitted', () => {
|
|
62
|
+
const telemetry = new RedocTelemetry({
|
|
63
|
+
specType: 'openapi',
|
|
64
|
+
serviceVersion: '1.0.0',
|
|
65
|
+
});
|
|
66
|
+
telemetry.send('Viewed');
|
|
67
|
+
expect(sendMock).toHaveBeenCalledTimes(1);
|
|
68
|
+
expect(sendMock).toHaveBeenCalledWith('Viewed', undefined);
|
|
69
|
+
});
|
|
70
|
+
it('calls super.send with event and data when data is not an array', () => {
|
|
71
|
+
const telemetry = new RedocTelemetry({
|
|
72
|
+
specType: 'openapi',
|
|
73
|
+
serviceVersion: '1.0.0',
|
|
74
|
+
});
|
|
75
|
+
const data = { foo: 'bar' };
|
|
76
|
+
telemetry.send('Viewed', data);
|
|
77
|
+
expect(sendMock).toHaveBeenCalledWith('Viewed', data);
|
|
78
|
+
});
|
|
79
|
+
it('enriches each object in array data with specType and calls super.send', () => {
|
|
80
|
+
const telemetry = new RedocTelemetry({
|
|
81
|
+
specType: 'asyncapi',
|
|
82
|
+
serviceVersion: '1.0.0',
|
|
83
|
+
});
|
|
84
|
+
const data = [{ id: 'a' }, { id: 'b' }];
|
|
85
|
+
telemetry.send('Viewed', data);
|
|
86
|
+
expect(sendMock).toHaveBeenCalledWith('Viewed', [
|
|
87
|
+
{ id: 'a', specType: 'asyncapi' },
|
|
88
|
+
{ id: 'b', specType: 'asyncapi' },
|
|
89
|
+
]);
|
|
90
|
+
});
|
|
91
|
+
it('passes through non-object array items unchanged', () => {
|
|
92
|
+
const telemetry = new RedocTelemetry({
|
|
93
|
+
specType: 'openapi',
|
|
94
|
+
serviceVersion: '1.0.0',
|
|
95
|
+
});
|
|
96
|
+
const data = [{ id: 'a' }, null, 'string', 42];
|
|
97
|
+
telemetry.send('Viewed', data);
|
|
98
|
+
expect(sendMock).toHaveBeenCalledWith('Viewed', [
|
|
99
|
+
{ id: 'a', specType: 'openapi' },
|
|
100
|
+
null,
|
|
101
|
+
'string',
|
|
102
|
+
42,
|
|
103
|
+
]);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
//# sourceMappingURL=RedocTelemetry.test.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ReactNode, ReactElement } from 'react';
|
|
2
|
+
import type { StoreProviderProps } from './components';
|
|
3
|
+
import type { BrowserRouterProps, MemoryRouterProps } from 'react-router';
|
|
4
|
+
export declare function TestBrowserRouter({ children, ...props }: BrowserRouterProps): ReactElement;
|
|
5
|
+
export declare function TestMemoryRouter({ children, ...props }: MemoryRouterProps): ReactElement;
|
|
6
|
+
export declare function withTestProviders(children: ReactNode, store?: StoreProviderProps): ReactElement;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Children } from 'react';
|
|
3
|
+
import { BrowserRouter, MemoryRouter } from 'react-router';
|
|
4
|
+
import { StoreProvider } from './components';
|
|
5
|
+
export function TestBrowserRouter({ children, ...props }) {
|
|
6
|
+
return _jsx(BrowserRouter, { ...props, children: children });
|
|
7
|
+
}
|
|
8
|
+
export function TestMemoryRouter({ children, ...props }) {
|
|
9
|
+
return _jsx(MemoryRouter, { ...props, children: children });
|
|
10
|
+
}
|
|
11
|
+
export function withTestProviders(children, store) {
|
|
12
|
+
return (_jsx(StoreProvider, { ...(store || { definition: { openapi: '3.0.0' } }), children: Children.only(children) }));
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=testProviders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { areArraysEqual } from '../areArraysEqual.js';
|
|
2
|
+
describe('areArraysEqual', () => {
|
|
3
|
+
it('should return true for two empty arrays', () => {
|
|
4
|
+
expect(areArraysEqual([], [])).toBe(true);
|
|
5
|
+
});
|
|
6
|
+
it('should return true for two identical arrays of primitives', () => {
|
|
7
|
+
expect(areArraysEqual([1, 2, 3], [1, 2, 3])).toBe(true);
|
|
8
|
+
});
|
|
9
|
+
it('should return false for arrays of different lengths', () => {
|
|
10
|
+
expect(areArraysEqual([1, 2, 3], [1, 2])).toBe(false);
|
|
11
|
+
});
|
|
12
|
+
it('should return false for arrays with the same length but different values', () => {
|
|
13
|
+
expect(areArraysEqual([1, 2, 3], [1, 2, 4])).toBe(false);
|
|
14
|
+
});
|
|
15
|
+
it('should return true for two identical arrays of strings', () => {
|
|
16
|
+
expect(areArraysEqual(['a', 'b', 'c'], ['a', 'b', 'c'])).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
it('should return false for arrays with different types', () => {
|
|
19
|
+
expect(areArraysEqual([1, '2', 3], [1, 2, 3])).toBe(false);
|
|
20
|
+
});
|
|
21
|
+
it('should handle arrays with undefined and null values correctly', () => {
|
|
22
|
+
expect(areArraysEqual([undefined, null], [undefined, null])).toBe(true);
|
|
23
|
+
expect(areArraysEqual([undefined, null], [null, undefined])).toBe(false);
|
|
24
|
+
});
|
|
25
|
+
it('should handle arrays with objects and arrays by reference equality', () => {
|
|
26
|
+
const obj1 = { a: 1 };
|
|
27
|
+
const obj2 = { a: 1 };
|
|
28
|
+
expect(areArraysEqual([obj1], [obj1])).toBe(true);
|
|
29
|
+
expect(areArraysEqual([obj1], [obj2])).toBe(false);
|
|
30
|
+
expect(areArraysEqual([[1, 2]], [[1, 2]])).toBe(false);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=areArraysEqual.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { argValueToBoolean, argValueToExpandLevel, argValueToInt, argValueToNumber, } from '../argValuesHelpers';
|
|
2
|
+
describe('argValuesHelpers tests', () => {
|
|
3
|
+
describe('argValueToBoolean function test', () => {
|
|
4
|
+
it('should return true when passing boolean value', () => {
|
|
5
|
+
const result = argValueToBoolean(true);
|
|
6
|
+
expect(result).toBe(true);
|
|
7
|
+
});
|
|
8
|
+
it('should return false value when nothing passing', () => {
|
|
9
|
+
const result = argValueToBoolean();
|
|
10
|
+
expect(result).toBe(false);
|
|
11
|
+
});
|
|
12
|
+
it('should return true whe passing some string', () => {
|
|
13
|
+
const result = argValueToBoolean('test');
|
|
14
|
+
expect(result).toBe(true);
|
|
15
|
+
});
|
|
16
|
+
it('should return false whe passing some `false` string', () => {
|
|
17
|
+
const result = argValueToBoolean('false');
|
|
18
|
+
expect(result).toBe(false);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
describe('argValueToExpandLevel function test', () => {
|
|
22
|
+
it('should return Infinity when passing `all`', () => {
|
|
23
|
+
const result = argValueToExpandLevel('all');
|
|
24
|
+
expect(result).toBe(Infinity);
|
|
25
|
+
});
|
|
26
|
+
it('should return undefined when call without arguments', () => {
|
|
27
|
+
const result = argValueToExpandLevel();
|
|
28
|
+
expect(result).toBe(undefined);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
describe('argValueToInt function test', () => {
|
|
32
|
+
it('should convert string number to number', () => {
|
|
33
|
+
const result = argValueToInt('22');
|
|
34
|
+
expect(result).toBe(22);
|
|
35
|
+
});
|
|
36
|
+
it('should Math.ceil number', () => {
|
|
37
|
+
const result = argValueToInt(22.4);
|
|
38
|
+
expect(result).toBe(23);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
describe('argValueToNumber function test', () => {
|
|
42
|
+
it('should return exact number', () => {
|
|
43
|
+
const result = argValueToNumber(22);
|
|
44
|
+
expect(result).toBe(22);
|
|
45
|
+
});
|
|
46
|
+
it('should parse string to number', () => {
|
|
47
|
+
const result = argValueToNumber('22');
|
|
48
|
+
expect(result).toBe(22);
|
|
49
|
+
});
|
|
50
|
+
it('should return default value', () => {
|
|
51
|
+
expect(argValueToNumber(undefined)).toBe(0);
|
|
52
|
+
expect(argValueToNumber(undefined, 2)).toBe(2);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=argValuesHelpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach } from 'vitest';
|
|
2
|
+
import { calculateMaxLength } from '../calculateMaxLength.js';
|
|
3
|
+
describe('calculateMaxLength', () => {
|
|
4
|
+
let measureEl;
|
|
5
|
+
beforeEach(() => {
|
|
6
|
+
measureEl = {
|
|
7
|
+
textContent: '',
|
|
8
|
+
scrollWidth: 0,
|
|
9
|
+
};
|
|
10
|
+
});
|
|
11
|
+
it('should return BREADCRUMB_MIN_LENGTH (10) when breadcrumbs array is empty', () => {
|
|
12
|
+
const result = calculateMaxLength([], 500, false, measureEl);
|
|
13
|
+
expect(result).toBe(10);
|
|
14
|
+
});
|
|
15
|
+
it('should return BREADCRUMB_MIN_LENGTH when availableWidth is zero or negative', () => {
|
|
16
|
+
const breadcrumbs = [
|
|
17
|
+
{ name: 'Home', href: '/' },
|
|
18
|
+
{ name: 'Products', href: '/products' },
|
|
19
|
+
];
|
|
20
|
+
expect(calculateMaxLength(breadcrumbs, 0, false, measureEl)).toBe(10);
|
|
21
|
+
expect(calculateMaxLength(breadcrumbs, -100, false, measureEl)).toBe(10);
|
|
22
|
+
});
|
|
23
|
+
it('should account for DROPDOWN_TRIGGER_WIDTH (40) when collapsed', () => {
|
|
24
|
+
const breadcrumbs = [
|
|
25
|
+
{ name: 'Short', href: '/' },
|
|
26
|
+
{ name: 'Name', href: '/name' },
|
|
27
|
+
];
|
|
28
|
+
let callCount = 0;
|
|
29
|
+
Object.defineProperty(measureEl, 'scrollWidth', {
|
|
30
|
+
get() {
|
|
31
|
+
callCount++;
|
|
32
|
+
if (callCount === 1)
|
|
33
|
+
return 5;
|
|
34
|
+
return this.textContent.length * 8;
|
|
35
|
+
},
|
|
36
|
+
configurable: true,
|
|
37
|
+
});
|
|
38
|
+
const collapsedResult = calculateMaxLength(breadcrumbs, 200, true, measureEl);
|
|
39
|
+
callCount = 0;
|
|
40
|
+
const expandedResult = calculateMaxLength(breadcrumbs, 200, false, measureEl);
|
|
41
|
+
expect(collapsedResult).toBeLessThanOrEqual(expandedResult);
|
|
42
|
+
});
|
|
43
|
+
it('should return max name length when breadcrumbs fit comfortably', () => {
|
|
44
|
+
const breadcrumbs = [
|
|
45
|
+
{ name: 'Home', href: '/' },
|
|
46
|
+
{ name: 'Products', href: '/products' },
|
|
47
|
+
{ name: 'Electronics', href: '/electronics' },
|
|
48
|
+
];
|
|
49
|
+
Object.defineProperty(measureEl, 'scrollWidth', {
|
|
50
|
+
get() {
|
|
51
|
+
return this.textContent === '/' ? 5 : this.textContent.length * 8;
|
|
52
|
+
},
|
|
53
|
+
configurable: true,
|
|
54
|
+
});
|
|
55
|
+
const result = calculateMaxLength(breadcrumbs, 1000, false, measureEl);
|
|
56
|
+
const maxNameLength = Math.max(...breadcrumbs.map((b) => b.name.length));
|
|
57
|
+
expect(result).toBe(maxNameLength);
|
|
58
|
+
});
|
|
59
|
+
it('should limit max length when available width is constrained', () => {
|
|
60
|
+
const breadcrumbs = [
|
|
61
|
+
{ name: 'VeryLongBreadcrumbName', href: '/' },
|
|
62
|
+
{ name: 'AnotherLongName', href: '/another' },
|
|
63
|
+
];
|
|
64
|
+
Object.defineProperty(measureEl, 'scrollWidth', {
|
|
65
|
+
get() {
|
|
66
|
+
return this.textContent === '/' ? 5 : this.textContent.length * 8;
|
|
67
|
+
},
|
|
68
|
+
configurable: true,
|
|
69
|
+
});
|
|
70
|
+
const result = calculateMaxLength(breadcrumbs, 150, false, measureEl);
|
|
71
|
+
expect(result).toBeLessThan(breadcrumbs[0].name.length);
|
|
72
|
+
expect(result).toBeGreaterThanOrEqual(10);
|
|
73
|
+
});
|
|
74
|
+
it('should handle breadcrumbs with varying name lengths', () => {
|
|
75
|
+
const breadcrumbs = [
|
|
76
|
+
{ name: 'Short', href: '/' },
|
|
77
|
+
{ name: 'MediumLength', href: '/medium' },
|
|
78
|
+
{ name: 'VeryVeryLongBreadcrumbName', href: '/long' },
|
|
79
|
+
];
|
|
80
|
+
Object.defineProperty(measureEl, 'scrollWidth', {
|
|
81
|
+
get() {
|
|
82
|
+
return this.textContent === '/' ? 5 : this.textContent.length * 8;
|
|
83
|
+
},
|
|
84
|
+
configurable: true,
|
|
85
|
+
});
|
|
86
|
+
const result = calculateMaxLength(breadcrumbs, 300, false, measureEl);
|
|
87
|
+
expect(result).toBeGreaterThanOrEqual(10);
|
|
88
|
+
expect(result).toBeLessThanOrEqual(breadcrumbs[2].name.length);
|
|
89
|
+
});
|
|
90
|
+
it('should handle many breadcrumbs with limited width', () => {
|
|
91
|
+
const breadcrumbs = Array.from({ length: 10 }, (_, i) => ({
|
|
92
|
+
name: `Level${i + 1}`,
|
|
93
|
+
href: `/level${i + 1}`,
|
|
94
|
+
}));
|
|
95
|
+
Object.defineProperty(measureEl, 'scrollWidth', {
|
|
96
|
+
get() {
|
|
97
|
+
return this.textContent === '/' ? 5 : this.textContent.length * 8;
|
|
98
|
+
},
|
|
99
|
+
configurable: true,
|
|
100
|
+
});
|
|
101
|
+
const result = calculateMaxLength(breadcrumbs, 400, false, measureEl);
|
|
102
|
+
expect(result).toBeGreaterThanOrEqual(10);
|
|
103
|
+
});
|
|
104
|
+
it('should enforce minimum length even with very constrained space', () => {
|
|
105
|
+
const breadcrumbs = [
|
|
106
|
+
{ name: 'A', href: '/' },
|
|
107
|
+
{ name: 'B', href: '/b' },
|
|
108
|
+
];
|
|
109
|
+
Object.defineProperty(measureEl, 'scrollWidth', {
|
|
110
|
+
get() {
|
|
111
|
+
return this.textContent === '/' ? 50 : this.textContent.length * 100;
|
|
112
|
+
},
|
|
113
|
+
configurable: true,
|
|
114
|
+
});
|
|
115
|
+
const result = calculateMaxLength(breadcrumbs, 50, false, measureEl);
|
|
116
|
+
expect(result).toBe(10);
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
//# sourceMappingURL=calculateMaxLength.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|