@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.
- package/lib/telemetry/RedocTelemetry.js +1 -31
- package/package.json +4 -4
- package/lib/components/ApiInfo/__tests__/ApiInfo.test.d.ts +0 -1
- package/lib/components/ApiInfo/__tests__/ApiInfo.test.js +0 -46
- package/lib/components/Callbacks/__tests__/Callbacks.test.d.ts +0 -1
- package/lib/components/Callbacks/__tests__/Callbacks.test.js +0 -46
- package/lib/components/Content/__tests__/useAutoScroll.test.d.ts +0 -1
- package/lib/components/Content/__tests__/useAutoScroll.test.js +0 -88
- package/lib/components/ContentItem/__tests__/useIsExpanded.test.d.ts +0 -1
- package/lib/components/ContentItem/__tests__/useIsExpanded.test.js +0 -123
- package/lib/components/ContentItems/__tests__/Items.test.d.ts +0 -1
- package/lib/components/ContentItems/__tests__/Items.test.js +0 -66
- package/lib/components/ContentItems/__tests__/VirtualList.test.d.ts +0 -1
- package/lib/components/ContentItems/__tests__/VirtualList.test.js +0 -135
- package/lib/components/Discriminator/__tests__/DiscriminatorDropdown.test.d.ts +0 -1
- package/lib/components/Discriminator/__tests__/DiscriminatorDropdown.test.js +0 -63
- package/lib/components/Download/__tests__/DownloadSpecification.test.d.ts +0 -1
- package/lib/components/Download/__tests__/DownloadSpecification.test.js +0 -52
- package/lib/components/ExpandAllButton/__tests__/ExpandAllButton.test.d.ts +0 -1
- package/lib/components/ExpandAllButton/__tests__/ExpandAllButton.test.js +0 -60
- package/lib/components/ExpandAllButton/__tests__/helpers.test.d.ts +0 -1
- package/lib/components/ExpandAllButton/__tests__/helpers.test.js +0 -133
- package/lib/components/Language/__tests__/LanguageDropdown.test.d.ts +0 -1
- package/lib/components/Language/__tests__/LanguageDropdown.test.js +0 -23
- package/lib/components/Markdown/__tests__/Markdown.test.d.ts +0 -1
- package/lib/components/Markdown/__tests__/Markdown.test.js +0 -34
- package/lib/components/McpOverview/__tests__/McpOverview.test.d.ts +0 -1
- package/lib/components/McpOverview/__tests__/McpOverview.test.js +0 -66
- package/lib/components/McpTool/__tests__/McpPrompt.test.d.ts +0 -1
- package/lib/components/McpTool/__tests__/McpPrompt.test.js +0 -57
- package/lib/components/McpTool/__tests__/McpResource.test.d.ts +0 -1
- package/lib/components/McpTool/__tests__/McpResource.test.js +0 -81
- package/lib/components/McpTool/__tests__/McpTool.test.d.ts +0 -1
- package/lib/components/McpTool/__tests__/McpTool.test.js +0 -82
- package/lib/components/MediaTypeSwitch/__tests__/MediaTypesSwitch.test.d.ts +0 -1
- package/lib/components/MediaTypeSwitch/__tests__/MediaTypesSwitch.test.js +0 -79
- package/lib/components/OperationItem/__tests__/OperationItem.test.d.ts +0 -1
- package/lib/components/OperationItem/__tests__/OperationItem.test.js +0 -70
- package/lib/components/OperationItem/__tests__/__mocks__/mock-intersection-observer.d.ts +0 -16
- package/lib/components/OperationItem/__tests__/__mocks__/mock-intersection-observer.js +0 -42
- package/lib/components/Overview/__tests__/Overview.test.d.ts +0 -1
- package/lib/components/Overview/__tests__/Overview.test.js +0 -59
- package/lib/components/PayloadSamples/__tests__/Example.test.d.ts +0 -1
- package/lib/components/PayloadSamples/__tests__/Example.test.js +0 -36
- package/lib/components/PayloadSamples/__tests__/ExampleValue.test.d.ts +0 -1
- package/lib/components/PayloadSamples/__tests__/ExampleValue.test.js +0 -197
- package/lib/components/PayloadSamples/__tests__/PayloadSamples.test.d.ts +0 -1
- package/lib/components/PayloadSamples/__tests__/PayloadSamples.test.js +0 -38
- package/lib/components/PropertyDetails/__tests__/Extensions.test.d.ts +0 -1
- package/lib/components/PropertyDetails/__tests__/Extensions.test.js +0 -21
- package/lib/components/PropertyDetails/__tests__/FieldDetail.test.d.ts +0 -1
- package/lib/components/PropertyDetails/__tests__/FieldDetail.test.js +0 -52
- package/lib/components/PropertyDetails/__tests__/FieldDetails.test.d.ts +0 -1
- package/lib/components/PropertyDetails/__tests__/FieldDetails.test.js +0 -191
- package/lib/components/PropertyDetails/__tests__/PropertyDetails.test.d.ts +0 -1
- package/lib/components/PropertyDetails/__tests__/PropertyDetails.test.js +0 -365
- package/lib/components/PropertyDetails/__tests__/cycleColorsByLevel.test.d.ts +0 -1
- package/lib/components/PropertyDetails/__tests__/cycleColorsByLevel.test.js +0 -23
- package/lib/components/RedoclyOpenAPIDocs/__tests__/AppProvider.test.d.ts +0 -1
- package/lib/components/RedoclyOpenAPIDocs/__tests__/AppProvider.test.js +0 -16
- package/lib/components/RedoclyOpenAPIDocs/__tests__/RedoclyOpenAPIDocs.test.d.ts +0 -1
- package/lib/components/RedoclyOpenAPIDocs/__tests__/RedoclyOpenAPIDocs.test.js +0 -104
- package/lib/components/RenderHook/__tests__/RenderHook.test.d.ts +0 -1
- package/lib/components/RenderHook/__tests__/RenderHook.test.js +0 -15
- package/lib/components/Replay/__tests__/utils.test.d.ts +0 -1
- package/lib/components/Replay/__tests__/utils.test.js +0 -526
- package/lib/components/Request/__tests__/RequestDetails.test.d.ts +0 -1
- package/lib/components/Request/__tests__/RequestDetails.test.js +0 -98
- package/lib/components/RequestSamples/__tests__/Example.test.d.ts +0 -1
- package/lib/components/RequestSamples/__tests__/Example.test.js +0 -384
- package/lib/components/RequestSamples/__tests__/RequestSamples.test.d.ts +0 -1
- package/lib/components/RequestSamples/__tests__/RequestSamples.test.js +0 -226
- package/lib/components/RequestSamples/__tests__/useCodeSamples.test.d.ts +0 -1
- package/lib/components/RequestSamples/__tests__/useCodeSamples.test.js +0 -64
- package/lib/components/ResponseSamples/__tests__/ResponseSamples.test.d.ts +0 -1
- package/lib/components/ResponseSamples/__tests__/ResponseSamples.test.js +0 -29
- package/lib/components/Responses/__tests__/OperationResponseList.test.d.ts +0 -1
- package/lib/components/Responses/__tests__/OperationResponseList.test.js +0 -89
- package/lib/components/Responses/__tests__/ResponseDetails.test.d.ts +0 -1
- package/lib/components/Responses/__tests__/ResponseDetails.test.js +0 -111
- package/lib/components/Responses/__tests__/ResponsesHeaders.test.d.ts +0 -1
- package/lib/components/Responses/__tests__/ResponsesHeaders.test.js +0 -26
- package/lib/components/Schema/__tests__/ArraySchema.test.d.ts +0 -1
- package/lib/components/Schema/__tests__/ArraySchema.test.js +0 -93
- package/lib/components/Schema/__tests__/ObjectSchema.test.d.ts +0 -1
- package/lib/components/Schema/__tests__/ObjectSchema.test.js +0 -115
- package/lib/components/Schema/__tests__/OneOfSchema.test.d.ts +0 -1
- package/lib/components/Schema/__tests__/OneOfSchema.test.js +0 -33
- package/lib/components/Schema/__tests__/Schema.test.d.ts +0 -1
- package/lib/components/Schema/__tests__/Schema.test.js +0 -67
- package/lib/components/Schema/__tests__/useOneOfLocationIdx.test.d.ts +0 -1
- package/lib/components/Schema/__tests__/useOneOfLocationIdx.test.js +0 -22
- package/lib/components/SchemaCatalogLink/__tests__/SchemaCatalogLink.test.d.ts +0 -1
- package/lib/components/SchemaCatalogLink/__tests__/SchemaCatalogLink.test.js +0 -95
- package/lib/components/Security/__tests__/Security.test.d.ts +0 -1
- package/lib/components/Security/__tests__/Security.test.js +0 -38
- package/lib/components/Security/__tests__/SecurityButton.test.d.ts +0 -1
- package/lib/components/Security/__tests__/SecurityButton.test.js +0 -92
- package/lib/components/Security/__tests__/SecurityModal.test.d.ts +0 -1
- package/lib/components/Security/__tests__/SecurityModal.test.js +0 -172
- package/lib/components/ServerList/__tests__/ServerList.test.d.ts +0 -1
- package/lib/components/ServerList/__tests__/ServerList.test.js +0 -83
- package/lib/components/Tabs/__tests__/Tabs.test.d.ts +0 -1
- package/lib/components/Tabs/__tests__/Tabs.test.js +0 -27
- package/lib/components/ViewNested/__tests__/ViewNested.test.d.ts +0 -1
- package/lib/components/ViewNested/__tests__/ViewNested.test.js +0 -42
- package/lib/components/__tests__/Samples/ExampleSwitch.test.d.ts +0 -1
- package/lib/components/__tests__/Samples/ExampleSwitch.test.js +0 -45
- package/lib/components/__tests__/Samples/use-example-key.test.d.ts +0 -1
- package/lib/components/__tests__/Samples/use-example-key.test.js +0 -28
- package/lib/components/__tests__/common/ClearButton.test.d.ts +0 -1
- package/lib/components/__tests__/common/ClearButton.test.js +0 -18
- package/lib/components/__tests__/common/Dropdown.test.d.ts +0 -1
- package/lib/components/__tests__/common/Dropdown.test.js +0 -52
- package/lib/components/__tests__/mocks/examples.d.ts +0 -4
- package/lib/components/__tests__/mocks/examples.js +0 -115
- package/lib/components/common/__tests__/Dropdown.test.d.ts +0 -1
- package/lib/components/common/__tests__/Dropdown.test.js +0 -129
- package/lib/components/common/__tests__/LinkToField.test.d.ts +0 -1
- package/lib/components/common/__tests__/LinkToField.test.js +0 -39
- package/lib/jotai/__tests__/app.test.d.ts +0 -1
- package/lib/jotai/__tests__/app.test.js +0 -53
- package/lib/models/__tests__/Callback.test.d.ts +0 -1
- package/lib/models/__tests__/Callback.test.js +0 -15
- package/lib/models/__tests__/FieldModel.test.d.ts +0 -1
- package/lib/models/__tests__/FieldModel.test.js +0 -117
- package/lib/models/__tests__/MediaContent.test.d.ts +0 -1
- package/lib/models/__tests__/MediaContent.test.js +0 -105
- package/lib/models/__tests__/Operation.test.d.ts +0 -1
- package/lib/models/__tests__/Operation.test.js +0 -459
- package/lib/models/__tests__/Response.test.d.ts +0 -1
- package/lib/models/__tests__/Response.test.js +0 -221
- package/lib/models/__tests__/Schema.circular.test.d.ts +0 -1
- package/lib/models/__tests__/Schema.circular.test.js +0 -694
- package/lib/models/__tests__/Schema.test.d.ts +0 -1
- package/lib/models/__tests__/Schema.test.js +0 -1395
- package/lib/models/__tests__/example.test.d.ts +0 -1
- package/lib/models/__tests__/example.test.js +0 -90
- package/lib/models/__tests__/group.test.d.ts +0 -1
- package/lib/models/__tests__/group.test.js +0 -52
- package/lib/models/__tests__/helpers.d.ts +0 -5
- package/lib/models/__tests__/helpers.js +0 -62
- package/lib/models/__tests__/request.test.d.ts +0 -1
- package/lib/models/__tests__/request.test.js +0 -119
- package/lib/services/__tests__/OpenAPIParser.test.d.ts +0 -1
- package/lib/services/__tests__/OpenAPIParser.test.js +0 -80
- package/lib/services/__tests__/check.test.d.ts +0 -1
- package/lib/services/__tests__/check.test.js +0 -22
- package/lib/services/__tests__/utils.test.d.ts +0 -1
- package/lib/services/__tests__/utils.test.js +0 -42
- package/lib/services/code-samples/__tests__/apply-environments.test.d.ts +0 -1
- package/lib/services/code-samples/__tests__/apply-environments.test.js +0 -64
- package/lib/services/code-samples/__tests__/build-code-samples.test.d.ts +0 -1
- package/lib/services/code-samples/__tests__/build-code-samples.test.js +0 -70
- package/lib/services/code-samples/__tests__/convertSampleToString.test.d.ts +0 -1
- package/lib/services/code-samples/__tests__/convertSampleToString.test.js +0 -116
- package/lib/services/code-samples/__tests__/generator-data-value.test.d.ts +0 -1
- package/lib/services/code-samples/__tests__/generator-data-value.test.js +0 -277
- package/lib/services/code-samples/__tests__/generator-serialized-value.test.d.ts +0 -1
- package/lib/services/code-samples/__tests__/generator-serialized-value.test.js +0 -258
- package/lib/services/code-samples/__tests__/generator-value.test.d.ts +0 -1
- package/lib/services/code-samples/__tests__/generator-value.test.js +0 -273
- package/lib/services/code-samples/__tests__/generator.test.d.ts +0 -249
- package/lib/services/code-samples/__tests__/generator.test.js +0 -1201
- package/lib/services/code-samples/__tests__/get-example-value-by-mime-type.test.d.ts +0 -1
- package/lib/services/code-samples/__tests__/get-example-value-by-mime-type.test.js +0 -31
- package/lib/services/code-samples/httpsnippet/__tests__/device-authorization.test.d.ts +0 -1
- package/lib/services/code-samples/httpsnippet/__tests__/device-authorization.test.js +0 -222
- package/lib/services/code-samples/httpsnippet/helpers/__tests__/code-helpers.test.d.ts +0 -1
- package/lib/services/code-samples/httpsnippet/helpers/__tests__/code-helpers.test.js +0 -129
- package/lib/services/code-samples/httpsnippet/helpers/__tests__/string-utility.test.d.ts +0 -1
- package/lib/services/code-samples/httpsnippet/helpers/__tests__/string-utility.test.js +0 -49
- package/lib/services/code-samples/httpsnippet/targets/csharp/__tests__/httpclient.test.d.ts +0 -1
- package/lib/services/code-samples/httpsnippet/targets/csharp/__tests__/httpclient.test.js +0 -172
- package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/__tests__/httpclient.test.d.ts +0 -1
- package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/__tests__/httpclient.test.js +0 -172
- package/lib/services/code-samples/httpsnippet/targets/go/__tests__/native.test.d.ts +0 -1
- package/lib/services/code-samples/httpsnippet/targets/go/__tests__/native.test.js +0 -130
- package/lib/services/code-samples/httpsnippet/targets/java/__tests__/httpclient.test.d.ts +0 -1
- package/lib/services/code-samples/httpsnippet/targets/java/__tests__/httpclient.test.js +0 -191
- package/lib/services/code-samples/httpsnippet/targets/java8/__tests__/apachehttp.test.d.ts +0 -1
- package/lib/services/code-samples/httpsnippet/targets/java8/__tests__/apachehttp.test.js +0 -172
- package/lib/services/code-samples/httpsnippet/targets/javascript/__tests__/fetch.test.d.ts +0 -1
- package/lib/services/code-samples/httpsnippet/targets/javascript/__tests__/fetch.test.js +0 -85
- package/lib/services/code-samples/httpsnippet/targets/node/__tests__/fetch.test.d.ts +0 -1
- package/lib/services/code-samples/httpsnippet/targets/node/__tests__/fetch.test.js +0 -85
- package/lib/services/code-samples/httpsnippet/targets/php/__tests__/curl.test.d.ts +0 -1
- package/lib/services/code-samples/httpsnippet/targets/php/__tests__/curl.test.js +0 -126
- package/lib/services/code-samples/httpsnippet/targets/python/__tests__/requests.test.d.ts +0 -1
- package/lib/services/code-samples/httpsnippet/targets/python/__tests__/requests.test.js +0 -105
- package/lib/services/code-samples/httpsnippet/targets/r/__tests__/httr.test.d.ts +0 -1
- package/lib/services/code-samples/httpsnippet/targets/r/__tests__/httr.test.js +0 -126
- package/lib/services/code-samples/httpsnippet/targets/ruby/__tests__/native.test.d.ts +0 -1
- package/lib/services/code-samples/httpsnippet/targets/ruby/__tests__/native.test.js +0 -129
- package/lib/services/code-samples/httpsnippet/targets/shell/__tests__/curl.test.d.ts +0 -1
- package/lib/services/code-samples/httpsnippet/targets/shell/__tests__/curl.test.js +0 -129
- package/lib/services/config-options/__tests__/helpers.test.d.ts +0 -1
- package/lib/services/config-options/__tests__/helpers.test.js +0 -234
- package/lib/services/history/__tests__/helpers.test.d.ts +0 -1
- package/lib/services/history/__tests__/helpers.test.js +0 -19
- package/lib/services/menu/__tests__/buildNestedTagsItems.test.d.ts +0 -1
- package/lib/services/menu/__tests__/buildNestedTagsItems.test.js +0 -109
- package/lib/services/menu/__tests__/builder.test.d.ts +0 -1
- package/lib/services/menu/__tests__/builder.test.js +0 -307
- package/lib/services/menu/__tests__/operation.test.d.ts +0 -1
- package/lib/services/menu/__tests__/operation.test.js +0 -240
- package/lib/services/menu/__tests__/tags.test.d.ts +0 -1
- package/lib/services/menu/__tests__/tags.test.js +0 -71
- package/lib/telemetry/__tests__/RedocTelemetry.test.d.ts +0 -1
- package/lib/telemetry/__tests__/RedocTelemetry.test.js +0 -107
- package/lib/testProviders.d.ts +0 -6
- package/lib/testProviders.js +0 -14
- package/lib/utils/__tests__/areArraysEqual.test.d.ts +0 -1
- package/lib/utils/__tests__/areArraysEqual.test.js +0 -33
- package/lib/utils/__tests__/argValuesHelpers.d.ts +0 -1
- package/lib/utils/__tests__/argValuesHelpers.js +0 -56
- package/lib/utils/__tests__/calculateMaxLength.test.d.ts +0 -1
- package/lib/utils/__tests__/calculateMaxLength.test.js +0 -119
- package/lib/utils/__tests__/configure-helpers.test.d.ts +0 -1
- package/lib/utils/__tests__/configure-helpers.test.js +0 -356
- package/lib/utils/__tests__/convertSwagger2OpenAPI.test.d.ts +0 -1
- package/lib/utils/__tests__/convertSwagger2OpenAPI.test.js +0 -392
- package/lib/utils/__tests__/debounce.test.d.ts +0 -1
- package/lib/utils/__tests__/debounce.test.js +0 -54
- package/lib/utils/__tests__/debug.test.d.ts +0 -1
- package/lib/utils/__tests__/debug.test.js +0 -23
- package/lib/utils/__tests__/dom.test.d.ts +0 -1
- package/lib/utils/__tests__/dom.test.js +0 -108
- package/lib/utils/__tests__/getBreadcrumbs.test.d.ts +0 -1
- package/lib/utils/__tests__/getBreadcrumbs.test.js +0 -98
- package/lib/utils/__tests__/hasNestedFields.test.d.ts +0 -1
- package/lib/utils/__tests__/hasNestedFields.test.js +0 -147
- package/lib/utils/__tests__/helpers.test.d.ts +0 -1
- package/lib/utils/__tests__/helpers.test.js +0 -174
- package/lib/utils/__tests__/isMobile.test.d.ts +0 -1
- package/lib/utils/__tests__/isMobile.test.js +0 -28
- package/lib/utils/__tests__/loadAndBundleSpec.test.d.ts +0 -1
- package/lib/utils/__tests__/loadAndBundleSpec.test.js +0 -22
- package/lib/utils/__tests__/local-storage.test.d.ts +0 -1
- package/lib/utils/__tests__/local-storage.test.js +0 -48
- package/lib/utils/__tests__/object.test.d.ts +0 -1
- package/lib/utils/__tests__/object.test.js +0 -45
- package/lib/utils/__tests__/openapi.test.d.ts +0 -1
- package/lib/utils/__tests__/openapi.test.js +0 -1378
- package/lib/utils/__tests__/path.test.d.ts +0 -1
- package/lib/utils/__tests__/path.test.js +0 -16
- package/lib/utils/__tests__/queryString.test.d.ts +0 -1
- package/lib/utils/__tests__/queryString.test.js +0 -60
- package/lib/utils/__tests__/replaceVariables.test.d.ts +0 -1
- package/lib/utils/__tests__/replaceVariables.test.js +0 -46
- package/lib/utils/__tests__/simplifyAstStructure.test.d.ts +0 -1
- package/lib/utils/__tests__/simplifyAstStructure.test.js +0 -26
- package/lib/utils/__tests__/sort.test.d.ts +0 -1
- package/lib/utils/__tests__/sort.test.js +0 -16
- package/lib/utils/__tests__/string.test.d.ts +0 -1
- package/lib/utils/__tests__/string.test.js +0 -16
- package/lib/utils/__tests__/theme-helpers.test.d.ts +0 -1
- package/lib/utils/__tests__/theme-helpers.test.js +0 -24
- package/lib/utils/__tests__/url.test.d.ts +0 -1
- package/lib/utils/__tests__/url.test.js +0 -134
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import * as Jotai from 'jotai';
|
|
4
|
-
import { vi } from 'vitest';
|
|
5
|
-
import { ServerList } from '../ServerList.js';
|
|
6
|
-
import { normalizeOptions } from '../../../services/index.js';
|
|
7
|
-
vi.mock('jotai', async () => ({
|
|
8
|
-
...(await vi.importActual('jotai')),
|
|
9
|
-
useAtomValue: vi.fn(),
|
|
10
|
-
}));
|
|
11
|
-
describe('ServerList component', () => {
|
|
12
|
-
vi.spyOn(Jotai, 'useAtomValue').mockReturnValue(normalizeOptions({}));
|
|
13
|
-
const servers = [
|
|
14
|
-
{
|
|
15
|
-
url: 'http://petstore.swagger.io/v2',
|
|
16
|
-
description: 'Default server',
|
|
17
|
-
name: 'Default',
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
url: 'http://petstore.swagger.io/sandbox',
|
|
21
|
-
description: 'Sandbox server',
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
url: 'http://petstore.swagger.io/stage',
|
|
25
|
-
name: 'Stage server',
|
|
26
|
-
},
|
|
27
|
-
];
|
|
28
|
-
const translateMock = vi.fn().mockImplementation((_, defaultValue) => defaultValue);
|
|
29
|
-
it('should render copy button', () => {
|
|
30
|
-
render(_jsx(ServerList, { servers: servers, path: "/pet", translate: translateMock }));
|
|
31
|
-
expect(screen.getAllByTestId('copy-button').length).toBe(3);
|
|
32
|
-
});
|
|
33
|
-
it('should render server description tooltip', () => {
|
|
34
|
-
render(_jsx(ServerList, { servers: servers, path: "/pet", translate: translateMock }));
|
|
35
|
-
expect(screen.getAllByTestId('server-item-description-tooltip').length).toBe(1);
|
|
36
|
-
});
|
|
37
|
-
it('should render server name', () => {
|
|
38
|
-
render(_jsx(ServerList, { servers: servers, path: "/pet", translate: translateMock }));
|
|
39
|
-
expect(screen.getAllByTestId('server-panel-item-name')[0]).toHaveTextContent('Default');
|
|
40
|
-
expect(screen.getAllByTestId('server-panel-item-name')[1]).toHaveTextContent('Sandbox server');
|
|
41
|
-
expect(screen.getAllByTestId('server-panel-item-name')[2]).toHaveTextContent('Stage server');
|
|
42
|
-
});
|
|
43
|
-
describe('Server variables', () => {
|
|
44
|
-
const serversWithVariables = [
|
|
45
|
-
{
|
|
46
|
-
url: 'http://petstore.swagger.io/{version}',
|
|
47
|
-
description: 'Default server with variables',
|
|
48
|
-
name: 'Default',
|
|
49
|
-
variables: {
|
|
50
|
-
version: {
|
|
51
|
-
default: 'v2',
|
|
52
|
-
description: 'API version',
|
|
53
|
-
enum: ['v1', 'v2'],
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
url: 'http://petstore.swagger.io/{sandbox}/{version}',
|
|
59
|
-
description: 'Sandbox server with variables',
|
|
60
|
-
variables: {
|
|
61
|
-
sandbox: {
|
|
62
|
-
default: 'dev',
|
|
63
|
-
description: 'Sandbox name',
|
|
64
|
-
},
|
|
65
|
-
version: {
|
|
66
|
-
default: 'v2',
|
|
67
|
-
description: 'API version',
|
|
68
|
-
enum: ['v1', 'v2'],
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
];
|
|
73
|
-
it('should render view nested with one variable', () => {
|
|
74
|
-
render(_jsx(ServerList, { servers: [serversWithVariables[0]], path: "/pet", translate: translateMock }));
|
|
75
|
-
expect(screen.getByText('Show 1 variable')).toBeInTheDocument();
|
|
76
|
-
});
|
|
77
|
-
it('should render view nested with multiple variables', () => {
|
|
78
|
-
render(_jsx(ServerList, { servers: [serversWithVariables[1]], path: "/pet", translate: translateMock }));
|
|
79
|
-
expect(screen.getByText('Show 2 variables')).toBeInTheDocument();
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
//# sourceMappingURL=ServerList.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { render, fireEvent } from '@testing-library/react';
|
|
3
|
-
import { Tabs } from '../Tabs.js';
|
|
4
|
-
import { useTabsState } from '../useTabsState.js';
|
|
5
|
-
describe('Tabs', () => {
|
|
6
|
-
const TestComponent = () => {
|
|
7
|
-
const tabs = [
|
|
8
|
-
{ key: 'tab1', title: 'Tab 1' },
|
|
9
|
-
{ key: 'tab2', title: 'Tab 2' },
|
|
10
|
-
];
|
|
11
|
-
const { activeTab, handleTabChange } = useTabsState({ tabs });
|
|
12
|
-
return (_jsxs("div", { children: [_jsx(Tabs, { tabs: tabs, activeTab: tabs[0], onChange: handleTabChange }), _jsx("div", { children: activeTab === tabs[0].key ? 'Content 1' : 'Content 2' })] }));
|
|
13
|
-
};
|
|
14
|
-
test('should render tab list and content components', () => {
|
|
15
|
-
const { getByText } = render(_jsx(TestComponent, {}));
|
|
16
|
-
expect(getByText('Tab 1')).toBeInTheDocument();
|
|
17
|
-
expect(getByText('Tab 2')).toBeInTheDocument();
|
|
18
|
-
expect(getByText(/Content 1/)).toBeInTheDocument();
|
|
19
|
-
});
|
|
20
|
-
test('should switch active tab when clicking on a Tab', () => {
|
|
21
|
-
const { getByText } = render(_jsx(TestComponent, {}));
|
|
22
|
-
const tab2 = getByText('Tab 2');
|
|
23
|
-
fireEvent.click(tab2);
|
|
24
|
-
expect(getByText(/Content 2/)).toBeInTheDocument();
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
//# sourceMappingURL=Tabs.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { ViewNested } from '../ViewNested.js';
|
|
4
|
-
describe('ViewNested', () => {
|
|
5
|
-
it('should render nested array content directly without show properties button', () => {
|
|
6
|
-
render(_jsx(ViewNested, { expandByDefault: false, isNestedArray: true, children: _jsx("div", { children: "Nested Array Content" }) }));
|
|
7
|
-
expect(screen.getByText('Nested Array Content')).toBeInTheDocument();
|
|
8
|
-
expect(screen.queryByText(/Show \d+ properties/)).toBeNull();
|
|
9
|
-
});
|
|
10
|
-
it('should auto-expand nested arrays', () => {
|
|
11
|
-
render(_jsx(ViewNested, { expandByDefault: false, isNestedArray: true, children: _jsx("div", { children: "Nested Content" }) }));
|
|
12
|
-
const nestedContent = screen.getByText('Nested Content');
|
|
13
|
-
expect(nestedContent).toBeVisible();
|
|
14
|
-
});
|
|
15
|
-
it('should expand via "Expand all" within the depth limit', () => {
|
|
16
|
-
render(_jsx(ViewNested, { expandByDefault: false, expandable: true, expandText: "Show 1 property", level: 5, expandedAll: true, children: _jsx("div", { children: "Deep Content" }) }));
|
|
17
|
-
expect(screen.getByText('Deep Content')).toBeInTheDocument();
|
|
18
|
-
expect(screen.queryByText('Show 1 property')).toBeNull();
|
|
19
|
-
});
|
|
20
|
-
it('should NOT auto-expand beyond the depth limit on "Expand all" (prevents freeze on DAG-shaped schemas)', () => {
|
|
21
|
-
render(_jsx(ViewNested, { expandByDefault: false, expandable: true, expandText: "Show 1 property", level: 50, expandedAll: true, children: _jsx("div", { children: "Very Deep Content" }) }));
|
|
22
|
-
// Stays collapsed: the node is still manually expandable, just not force-expanded.
|
|
23
|
-
expect(screen.queryByText('Very Deep Content')).toBeNull();
|
|
24
|
-
expect(screen.getByText('Show 1 property')).toBeInTheDocument();
|
|
25
|
-
});
|
|
26
|
-
it('should respect the adaptive expandAllDepth over the default ceiling', () => {
|
|
27
|
-
render(_jsx(ViewNested, { expandByDefault: false, expandable: true, expandText: "Show 1 property", level: 6, expandedAll: true, expandAllDepth: 5, children: _jsx("div", { children: "Adaptive Deep Content" }) }));
|
|
28
|
-
expect(screen.queryByText('Adaptive Deep Content')).toBeNull();
|
|
29
|
-
expect(screen.getByText('Show 1 property')).toBeInTheDocument();
|
|
30
|
-
});
|
|
31
|
-
it('should cap expandAllDepth by the ceiling even when the budget allows more', () => {
|
|
32
|
-
render(_jsx(ViewNested, { expandByDefault: false, expandable: true, expandText: "Show 1 property", level: 12, expandedAll: true, expandAllDepth: 15, children: _jsx("div", { children: "Beyond Ceiling Content" }) }));
|
|
33
|
-
expect(screen.queryByText('Beyond Ceiling Content')).toBeNull();
|
|
34
|
-
expect(screen.getByText('Show 1 property')).toBeInTheDocument();
|
|
35
|
-
});
|
|
36
|
-
it('should always collapse on "Collapse all" regardless of depth', () => {
|
|
37
|
-
render(_jsx(ViewNested, { expandByDefault: true, expandable: true, expandText: "Show 1 property", level: 50, expandedAll: false, children: _jsx("div", { children: "Deep Content To Collapse" }) }));
|
|
38
|
-
expect(screen.queryByText('Deep Content To Collapse')).toBeNull();
|
|
39
|
-
expect(screen.getByText('Show 1 property')).toBeInTheDocument();
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
//# sourceMappingURL=ViewNested.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { render, fireEvent } from '@testing-library/react';
|
|
3
|
-
import { ExampleSwitch } from '../../Samples/index.js';
|
|
4
|
-
import { exampleXML, examples } from '../mocks/examples.js';
|
|
5
|
-
describe('ExampleSwitch', () => {
|
|
6
|
-
const exampleKey = 'cat';
|
|
7
|
-
it('should correctly render ExampleSwitch', () => {
|
|
8
|
-
const { getByTestId, getAllByRole } = render(_jsx(ExampleSwitch, { exampleKey: exampleKey, examples: examples, onChange: () => { } }));
|
|
9
|
-
expect(getByTestId('dropdown')).toBeInTheDocument();
|
|
10
|
-
const triggerButton = getByTestId('dropdown').querySelector('button');
|
|
11
|
-
if (triggerButton) {
|
|
12
|
-
fireEvent.click(triggerButton);
|
|
13
|
-
}
|
|
14
|
-
const menuItems = getAllByRole('menuitem');
|
|
15
|
-
expect(menuItems.length).toBe(3);
|
|
16
|
-
});
|
|
17
|
-
it('should correctly display ExampleSwitch with a different number of examples in the media type', () => {
|
|
18
|
-
let examplesObj = {
|
|
19
|
-
exampleKey: 'bee',
|
|
20
|
-
examples: examples,
|
|
21
|
-
};
|
|
22
|
-
const { getByTestId, getAllByRole, rerender } = render(_jsx(ExampleSwitch, { exampleKey: examplesObj.exampleKey, examples: examplesObj.examples, onChange: () => { } }));
|
|
23
|
-
expect(getByTestId('dropdown')).toBeInTheDocument();
|
|
24
|
-
let triggerButton = getByTestId('dropdown').querySelector('button');
|
|
25
|
-
if (triggerButton) {
|
|
26
|
-
fireEvent.click(triggerButton);
|
|
27
|
-
}
|
|
28
|
-
expect(getAllByRole('menuitem').length).toBe(3);
|
|
29
|
-
if (triggerButton) {
|
|
30
|
-
fireEvent.click(triggerButton);
|
|
31
|
-
}
|
|
32
|
-
examplesObj = {
|
|
33
|
-
exampleKey: 'foo',
|
|
34
|
-
examples: exampleXML,
|
|
35
|
-
};
|
|
36
|
-
rerender(_jsx(ExampleSwitch, { exampleKey: examplesObj.exampleKey, examples: examplesObj.examples, onChange: () => { } }));
|
|
37
|
-
expect(getByTestId('dropdown')).toBeInTheDocument();
|
|
38
|
-
triggerButton = getByTestId('dropdown').querySelector('button');
|
|
39
|
-
if (triggerButton) {
|
|
40
|
-
fireEvent.click(triggerButton);
|
|
41
|
-
}
|
|
42
|
-
expect(getAllByRole('menuitem').length).toBe(2);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
//# sourceMappingURL=ExampleSwitch.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { renderHook } from '@testing-library/react';
|
|
2
|
-
import { normalizeOptions, OpenAPIParser, } from '../../../services/index.js';
|
|
3
|
-
import { getOperation } from '../../../models/index.js';
|
|
4
|
-
import testDefinition from '../../MediaTypeSwitch/__tests__/fixtures/test-definition.json';
|
|
5
|
-
import { useExampleKey } from '../../Samples/use-example-key.js';
|
|
6
|
-
describe('useExampleKey method', () => {
|
|
7
|
-
const options = normalizeOptions({});
|
|
8
|
-
const parser = new OpenAPIParser(testDefinition, undefined, options);
|
|
9
|
-
test('should take firstKey as exampleKey if activeExampleName and defaultExampleName are missing', () => {
|
|
10
|
-
const operation = getOperation(parser, {
|
|
11
|
-
pointer: '#/paths/~1test/get',
|
|
12
|
-
pathName: '/test',
|
|
13
|
-
httpVerb: 'GET',
|
|
14
|
-
pathParameters: [],
|
|
15
|
-
pathServers: [],
|
|
16
|
-
isWebhook: false,
|
|
17
|
-
operationId: 'getPet',
|
|
18
|
-
...testDefinition.paths['/test'].get,
|
|
19
|
-
}, undefined, options, '');
|
|
20
|
-
const { result } = renderHook(() => useExampleKey(operation, { key: 'test' }));
|
|
21
|
-
expect(result.current.exampleKey).toBe('key');
|
|
22
|
-
});
|
|
23
|
-
test('should not brake if no operation passed and should take firstKey as exampleKey', () => {
|
|
24
|
-
const { result } = renderHook(() => useExampleKey(undefined, { key: 'test' }));
|
|
25
|
-
expect(result.current.exampleKey).toBe('key');
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
//# sourceMappingURL=use-example-key.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { vi } from 'vitest';
|
|
3
|
-
import { render } from '@testing-library/react';
|
|
4
|
-
import userEvent from '@testing-library/user-event';
|
|
5
|
-
import { ClearButton } from '../../common/ClearButton/index.js';
|
|
6
|
-
describe('ClearButton component', () => {
|
|
7
|
-
const handleClear = vi.fn();
|
|
8
|
-
it('render component correctly', () => {
|
|
9
|
-
const { container } = render(_jsx(ClearButton, { handleClear: handleClear }));
|
|
10
|
-
expect(container).toMatchSnapshot();
|
|
11
|
-
});
|
|
12
|
-
it('trigger `handleClear` func on click', async () => {
|
|
13
|
-
const { getByRole } = render(_jsx(ClearButton, { handleClear: handleClear }));
|
|
14
|
-
await userEvent.click(getByRole('button'));
|
|
15
|
-
expect(handleClear).toHaveBeenCalled();
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
//# sourceMappingURL=ClearButton.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { render, fireEvent } from '@testing-library/react';
|
|
3
|
-
import { Select, SimpleSelect } from '../../common/Select/index.js';
|
|
4
|
-
describe('Select component', () => {
|
|
5
|
-
const onChange = vi.fn();
|
|
6
|
-
const options = [
|
|
7
|
-
{ idx: 0, title: 'First option', value: 'option1' },
|
|
8
|
-
{ idx: 1, title: 'Second option', value: 'option2' },
|
|
9
|
-
];
|
|
10
|
-
afterEach(() => {
|
|
11
|
-
vi.clearAllMocks();
|
|
12
|
-
});
|
|
13
|
-
it('render Select component correctly', () => {
|
|
14
|
-
const { container, getByTestId, getAllByRole } = render(_jsx(Select, { variant: "dark", options: options, value: options[0].value, onChange: onChange }));
|
|
15
|
-
expect(container.firstChild).toMatchSnapshot();
|
|
16
|
-
const dropdown = getByTestId('dropdown');
|
|
17
|
-
const triggerButton = dropdown.querySelector('button');
|
|
18
|
-
expect(triggerButton).toBeInTheDocument();
|
|
19
|
-
if (triggerButton) {
|
|
20
|
-
fireEvent.click(triggerButton);
|
|
21
|
-
}
|
|
22
|
-
const menuItems = getAllByRole('menuitem');
|
|
23
|
-
fireEvent.click(menuItems[1]);
|
|
24
|
-
expect(onChange).toHaveBeenCalled();
|
|
25
|
-
});
|
|
26
|
-
it('render SimpleSelect dark variant correctly', () => {
|
|
27
|
-
const { container, getByTestId, getAllByRole } = render(_jsx(SimpleSelect, { variant: "dark", options: options, value: options[0].value, onChange: onChange }));
|
|
28
|
-
expect(container.firstChild).toMatchSnapshot();
|
|
29
|
-
const dropdown = getByTestId('dropdown');
|
|
30
|
-
const triggerButton = dropdown.querySelector('button');
|
|
31
|
-
expect(triggerButton).toBeInTheDocument();
|
|
32
|
-
if (triggerButton) {
|
|
33
|
-
fireEvent.click(triggerButton);
|
|
34
|
-
}
|
|
35
|
-
const menuItems = getAllByRole('menuitem');
|
|
36
|
-
fireEvent.click(menuItems[1]);
|
|
37
|
-
expect(onChange).toHaveBeenCalled();
|
|
38
|
-
});
|
|
39
|
-
it('render Select with empty init value', () => {
|
|
40
|
-
const { getByTestId, getAllByRole } = render(_jsx(Select, { variant: "dark", options: options, value: "", onChange: onChange }));
|
|
41
|
-
const dropdown = getByTestId('dropdown');
|
|
42
|
-
const triggerButton = dropdown.querySelector('button');
|
|
43
|
-
if (triggerButton) {
|
|
44
|
-
fireEvent.click(triggerButton);
|
|
45
|
-
}
|
|
46
|
-
const menuItems = getAllByRole('menuitem');
|
|
47
|
-
expect(menuItems[0]).toHaveTextContent('First option');
|
|
48
|
-
fireEvent.click(menuItems[1]);
|
|
49
|
-
expect(onChange).toHaveBeenCalled();
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
//# sourceMappingURL=Dropdown.test.js.map
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
export const examples = {
|
|
2
|
-
cat: {
|
|
3
|
-
mime: 'application/json',
|
|
4
|
-
value: {
|
|
5
|
-
category: {
|
|
6
|
-
name: 'string',
|
|
7
|
-
sub: {
|
|
8
|
-
prop1: 'string',
|
|
9
|
-
},
|
|
10
|
-
},
|
|
11
|
-
name: 'Guru',
|
|
12
|
-
photoUrls: ['string'],
|
|
13
|
-
friend: {},
|
|
14
|
-
tags: [
|
|
15
|
-
{
|
|
16
|
-
name: 'string',
|
|
17
|
-
},
|
|
18
|
-
],
|
|
19
|
-
cvv_check: 'string',
|
|
20
|
-
status: 'available',
|
|
21
|
-
petType: 'cat',
|
|
22
|
-
huntingSkill: 'adventurous',
|
|
23
|
-
},
|
|
24
|
-
rawValue: {},
|
|
25
|
-
},
|
|
26
|
-
dog: {
|
|
27
|
-
mime: 'application/json',
|
|
28
|
-
value: {
|
|
29
|
-
category: {
|
|
30
|
-
name: 'string',
|
|
31
|
-
sub: {
|
|
32
|
-
prop1: 'string',
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
name: 'Guru',
|
|
36
|
-
photoUrls: ['string'],
|
|
37
|
-
friend: {},
|
|
38
|
-
tags: [
|
|
39
|
-
{
|
|
40
|
-
name: 'string',
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
cvv_check: 'string',
|
|
44
|
-
status: 'available',
|
|
45
|
-
petType: 'dog',
|
|
46
|
-
packSize: 1,
|
|
47
|
-
},
|
|
48
|
-
rawValue: {},
|
|
49
|
-
},
|
|
50
|
-
bee: {
|
|
51
|
-
mime: 'application/json',
|
|
52
|
-
value: {
|
|
53
|
-
category: {
|
|
54
|
-
name: 'string',
|
|
55
|
-
sub: {
|
|
56
|
-
prop1: 'string',
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
name: 'Guru',
|
|
60
|
-
photoUrls: ['string'],
|
|
61
|
-
friend: {},
|
|
62
|
-
tags: [
|
|
63
|
-
{
|
|
64
|
-
name: 'string',
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
cvv_check: 'string',
|
|
68
|
-
status: 'available',
|
|
69
|
-
petType: 'bee',
|
|
70
|
-
honeyPerDay: 3.14,
|
|
71
|
-
},
|
|
72
|
-
rawValue: {},
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
export const examplesJSON = {
|
|
76
|
-
foo: {
|
|
77
|
-
mime: 'application/json',
|
|
78
|
-
value: {
|
|
79
|
-
foo: 'bar',
|
|
80
|
-
},
|
|
81
|
-
rawValue: {
|
|
82
|
-
foo: 'bar',
|
|
83
|
-
},
|
|
84
|
-
summary: 'A foo example',
|
|
85
|
-
},
|
|
86
|
-
bar: {
|
|
87
|
-
mime: 'application/json',
|
|
88
|
-
value: {
|
|
89
|
-
bar: 'baz',
|
|
90
|
-
},
|
|
91
|
-
rawValue: {
|
|
92
|
-
bar: 'baz',
|
|
93
|
-
},
|
|
94
|
-
summary: 'A bar example',
|
|
95
|
-
},
|
|
96
|
-
};
|
|
97
|
-
export const exampleXML = {
|
|
98
|
-
xmlExample: {
|
|
99
|
-
rawValue: undefined,
|
|
100
|
-
value: undefined,
|
|
101
|
-
mime: 'application/xml',
|
|
102
|
-
summary: 'This is an example in XML',
|
|
103
|
-
},
|
|
104
|
-
foo: {
|
|
105
|
-
mime: 'application/xml',
|
|
106
|
-
value: {
|
|
107
|
-
foo: 'bar',
|
|
108
|
-
},
|
|
109
|
-
rawValue: {
|
|
110
|
-
foo: 'bar',
|
|
111
|
-
},
|
|
112
|
-
summary: 'A foo example',
|
|
113
|
-
},
|
|
114
|
-
};
|
|
115
|
-
//# sourceMappingURL=examples.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { render, fireEvent, screen } from '@testing-library/react';
|
|
3
|
-
import { Dropdown } from '../Dropdown/index.js';
|
|
4
|
-
describe('DropdownComponent', () => {
|
|
5
|
-
const options = [
|
|
6
|
-
{ value: 'option1', label: 'Option 1' },
|
|
7
|
-
{ value: 'option2', label: 'Option 2' },
|
|
8
|
-
{ value: 'option3', label: 'Option 3' },
|
|
9
|
-
];
|
|
10
|
-
const value = 'option1';
|
|
11
|
-
const onChange = vi.fn();
|
|
12
|
-
const defaultProps = {
|
|
13
|
-
options,
|
|
14
|
-
value,
|
|
15
|
-
onChange,
|
|
16
|
-
className: 'custom-dropdown',
|
|
17
|
-
};
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
vi.clearAllMocks();
|
|
20
|
-
});
|
|
21
|
-
it('renders dropdown options correctly', () => {
|
|
22
|
-
const { getAllByText, getByRole } = render(_jsx(Dropdown, { ...defaultProps }));
|
|
23
|
-
fireEvent.click(getByRole('button'));
|
|
24
|
-
options.forEach((option) => {
|
|
25
|
-
const elements = getAllByText(option.label);
|
|
26
|
-
expect(elements.length).toBeGreaterThan(0);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
it('calls onChange callback when an option is clicked', () => {
|
|
30
|
-
const { getByText, getByRole } = render(_jsx(Dropdown, { ...defaultProps }));
|
|
31
|
-
fireEvent.click(getByRole('button'));
|
|
32
|
-
fireEvent.click(getByText('Option 2'));
|
|
33
|
-
expect(onChange).toHaveBeenCalledWith(options[1]);
|
|
34
|
-
});
|
|
35
|
-
it('calls onChange callback when Enter key is pressed on an option', () => {
|
|
36
|
-
const { getByText, getByRole } = render(_jsx(Dropdown, { ...defaultProps }));
|
|
37
|
-
fireEvent.click(getByRole('button'));
|
|
38
|
-
fireEvent.keyDown(getByText('Option 3'), { key: 'Enter' });
|
|
39
|
-
expect(onChange).toHaveBeenCalledWith(options[2]);
|
|
40
|
-
});
|
|
41
|
-
it('renders title correctly', () => {
|
|
42
|
-
const { getAllByText } = render(_jsx(Dropdown, { ...defaultProps }));
|
|
43
|
-
expect(getAllByText('Option 1')[0]).toBeInTheDocument();
|
|
44
|
-
});
|
|
45
|
-
it('renders title when there is only one option', () => {
|
|
46
|
-
const singleOption = [{ value: 'option1', label: 'Option 1' }];
|
|
47
|
-
const singleOptionProps = {
|
|
48
|
-
options: singleOption,
|
|
49
|
-
value: 'option1',
|
|
50
|
-
onChange,
|
|
51
|
-
className: 'custom-dropdown',
|
|
52
|
-
};
|
|
53
|
-
const { getByText } = render(_jsx(Dropdown, { ...singleOptionProps }));
|
|
54
|
-
expect(getByText('Option 1')).toBeInTheDocument();
|
|
55
|
-
});
|
|
56
|
-
describe('search functionality (auto-enabled with 7+ options)', () => {
|
|
57
|
-
const searchOptions = [
|
|
58
|
-
{ value: 'apple', label: 'Apple' },
|
|
59
|
-
{ value: 'banana', label: 'Banana' },
|
|
60
|
-
{ value: 'cherry', label: 'Cherry' },
|
|
61
|
-
{ value: 'date', label: 'Date' },
|
|
62
|
-
{ value: 'elderberry', label: 'Elderberry' },
|
|
63
|
-
{ value: 'fig', label: 'Fig' },
|
|
64
|
-
{ value: 'grape', label: 'Grape' },
|
|
65
|
-
];
|
|
66
|
-
const searchProps = {
|
|
67
|
-
options: searchOptions,
|
|
68
|
-
value: 'apple',
|
|
69
|
-
onChange,
|
|
70
|
-
};
|
|
71
|
-
it('renders search input when there are 7 or more options', () => {
|
|
72
|
-
render(_jsx(Dropdown, { ...searchProps }));
|
|
73
|
-
fireEvent.click(screen.getByRole('button'));
|
|
74
|
-
const searchInput = screen.getByPlaceholderText('Search items');
|
|
75
|
-
expect(searchInput).toBeInTheDocument();
|
|
76
|
-
});
|
|
77
|
-
it('does not render search input when there are fewer than 7 options', () => {
|
|
78
|
-
render(_jsx(Dropdown, { ...defaultProps }));
|
|
79
|
-
fireEvent.click(screen.getByRole('button'));
|
|
80
|
-
const searchInput = screen.queryByPlaceholderText('Search items');
|
|
81
|
-
expect(searchInput).not.toBeInTheDocument();
|
|
82
|
-
});
|
|
83
|
-
it('filters options based on search input', () => {
|
|
84
|
-
render(_jsx(Dropdown, { ...searchProps }));
|
|
85
|
-
fireEvent.click(screen.getByRole('button'));
|
|
86
|
-
const searchInput = screen.getByPlaceholderText('Search items');
|
|
87
|
-
fireEvent.change(searchInput, { target: { value: 'an' } });
|
|
88
|
-
const menu = screen.getByTestId('dropdown-menu');
|
|
89
|
-
expect(menu).toHaveTextContent('Banana');
|
|
90
|
-
const menuItems = screen.getAllByRole('menuitem');
|
|
91
|
-
const menuItemTexts = menuItems.map((item) => item.textContent);
|
|
92
|
-
expect(menuItemTexts.some((text) => text?.includes('Banana'))).toBe(true);
|
|
93
|
-
expect(menuItemTexts.filter((text) => text?.includes('Cherry'))).toHaveLength(0);
|
|
94
|
-
});
|
|
95
|
-
it('filters options case-insensitively', () => {
|
|
96
|
-
render(_jsx(Dropdown, { ...searchProps }));
|
|
97
|
-
fireEvent.click(screen.getByRole('button'));
|
|
98
|
-
const searchInput = screen.getByPlaceholderText('Search items');
|
|
99
|
-
fireEvent.change(searchInput, { target: { value: 'banana' } });
|
|
100
|
-
const menu = screen.getByTestId('dropdown-menu');
|
|
101
|
-
expect(menu).toHaveTextContent('Banana');
|
|
102
|
-
const menuItems = screen.getAllByRole('menuitem');
|
|
103
|
-
const fruitItems = menuItems.filter((item) => !item.querySelector('input'));
|
|
104
|
-
expect(fruitItems).toHaveLength(1);
|
|
105
|
-
expect(fruitItems[0]).toHaveTextContent('Banana');
|
|
106
|
-
});
|
|
107
|
-
it('shows "No items found" when no options match search', () => {
|
|
108
|
-
render(_jsx(Dropdown, { ...searchProps }));
|
|
109
|
-
fireEvent.click(screen.getByRole('button'));
|
|
110
|
-
const searchInput = screen.getByPlaceholderText('Search items');
|
|
111
|
-
fireEvent.change(searchInput, { target: { value: 'xyz' } });
|
|
112
|
-
expect(screen.getByText('No items found')).toBeInTheDocument();
|
|
113
|
-
const menuItems = screen.getAllByRole('menuitem');
|
|
114
|
-
const fruitItems = menuItems.filter((item) => !item.querySelector('input') && !item.textContent?.includes('No items found'));
|
|
115
|
-
expect(fruitItems).toHaveLength(0);
|
|
116
|
-
});
|
|
117
|
-
it('handles empty search input correctly', () => {
|
|
118
|
-
render(_jsx(Dropdown, { ...searchProps }));
|
|
119
|
-
fireEvent.click(screen.getByRole('button'));
|
|
120
|
-
const searchInput = screen.getByPlaceholderText('Search items');
|
|
121
|
-
fireEvent.change(searchInput, { target: { value: '' } });
|
|
122
|
-
const menu = screen.getByTestId('dropdown-menu');
|
|
123
|
-
searchOptions.forEach((option) => {
|
|
124
|
-
expect(menu).toHaveTextContent(option.label);
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
//# sourceMappingURL=Dropdown.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { generateDeepLink } from '../LinkToField.js';
|
|
2
|
-
import { normalizeOptions, OpenAPIParser } from '../../../services/index.js';
|
|
3
|
-
import { getField } from '../../../models/index.js';
|
|
4
|
-
import spec from './fixtures/simpleOpenAPI.json';
|
|
5
|
-
const options = normalizeOptions({});
|
|
6
|
-
describe('generateDeepLink', () => {
|
|
7
|
-
const parser = new OpenAPIParser(spec, undefined, options);
|
|
8
|
-
const deps = {
|
|
9
|
-
type: 'request',
|
|
10
|
-
operation: {
|
|
11
|
-
id: 'paths/~1pets/post',
|
|
12
|
-
pointer: '/paths/~1pets/post',
|
|
13
|
-
href: '/paths/~1pets/post',
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
const field = getField(parser, {
|
|
17
|
-
name: 'name',
|
|
18
|
-
required: false,
|
|
19
|
-
schema: {
|
|
20
|
-
type: 'string',
|
|
21
|
-
},
|
|
22
|
-
}, '/properties/name', options, deps);
|
|
23
|
-
it('generates a deep link for a field without an operation', () => {
|
|
24
|
-
const field = getField(parser, {
|
|
25
|
-
name: 'name',
|
|
26
|
-
required: false,
|
|
27
|
-
schema: {
|
|
28
|
-
type: 'string',
|
|
29
|
-
},
|
|
30
|
-
}, '/properties/name', options, { ...deps, operation: {} });
|
|
31
|
-
const deepLink = generateDeepLink(field);
|
|
32
|
-
expect(deepLink).toBe('#t=request&path=name');
|
|
33
|
-
});
|
|
34
|
-
it('generates a deep link with the default deepLinkPrefix', () => {
|
|
35
|
-
const deepLink = generateDeepLink(field);
|
|
36
|
-
expect(deepLink).toBe('/paths/~1pets/post#paths/~1pets/post/t=request&path=name');
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
//# sourceMappingURL=LinkToField.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|