docusaurus-plugin-openapi-docs 0.0.0-1155 → 0.0.0-1156

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.
@@ -1,208 +0,0 @@
1
- /* ============================================================================
2
- * Copyright (c) Palo Alto Networks
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- * ========================================================================== */
7
-
8
- import { getQualifierMessage } from "./schema";
9
-
10
- describe("getQualifierMessage", () => {
11
- it("should render nothing", () => {
12
- const actual = getQualifierMessage({});
13
- expect(actual).toBeUndefined();
14
- });
15
-
16
- //
17
- // minLength + maxLength
18
- //
19
- it("should render minLength", () => {
20
- const expected = "**Possible values:** `non-empty`";
21
- const actual = getQualifierMessage({ minLength: 1 });
22
- expect(actual).toBe(expected);
23
- });
24
-
25
- it("should render maxLength", () => {
26
- const expected = "**Possible values:** `<= 40 characters`";
27
- const actual = getQualifierMessage({ maxLength: 40 });
28
- expect(actual).toBe(expected);
29
- });
30
-
31
- it("should render minLength and maxLength", () => {
32
- const expected = "**Possible values:** `non-empty` and `<= 40 characters`";
33
- const actual = getQualifierMessage({ minLength: 1, maxLength: 40 });
34
- expect(actual).toBe(expected);
35
- });
36
-
37
- //
38
- // pattern
39
- //
40
- it("should render pattern", () => {
41
- const expected =
42
- "**Possible values:** Value must match regular expression `^[a-zA-Z0-9_-]*$`";
43
- const actual = getQualifierMessage({ pattern: "^[a-zA-Z0-9_-]*$" });
44
- expect(actual).toBe(expected);
45
- });
46
-
47
- it("should render multiple string qualifiers", () => {
48
- const expected =
49
- "**Possible values:** `non-empty` and `<= 40 characters`, Value must match regular expression `^[a-zA-Z0-9_-]*$`";
50
- const actual = getQualifierMessage({
51
- minLength: 1,
52
- maxLength: 40,
53
- pattern: "^[a-zA-Z0-9_-]*$",
54
- });
55
- expect(actual).toBe(expected);
56
- });
57
-
58
- //
59
- // enum
60
- //
61
- it("should render enum", () => {
62
- const expected = "**Possible values:** [`cat`, `dog`, `mouse`]";
63
- const actual = getQualifierMessage({ enum: ["cat", "dog", "mouse"] });
64
- expect(actual).toBe(expected);
65
- });
66
-
67
- //
68
- // minimum + maximum + exclusiveMinimum + exclusiveMaximum
69
- //
70
- it("should render minimum", () => {
71
- const expected = "**Possible values:** `>= 1`";
72
- const actual = getQualifierMessage({ minimum: 1 });
73
- expect(actual).toBe(expected);
74
- });
75
-
76
- it("should render maximum", () => {
77
- const expected = "**Possible values:** `<= 40`";
78
- const actual = getQualifierMessage({ maximum: 40 });
79
- expect(actual).toBe(expected);
80
- });
81
-
82
- it("should render numeric exclusiveMinimum", () => {
83
- const expected = "**Possible values:** `> 1`";
84
- const actual = getQualifierMessage({ exclusiveMinimum: 1 });
85
- expect(actual).toBe(expected);
86
- });
87
-
88
- it("should render numeric exclusiveMaximum", () => {
89
- const expected = "**Possible values:** `< 40`";
90
- const actual = getQualifierMessage({ exclusiveMaximum: 40 });
91
- expect(actual).toBe(expected);
92
- });
93
-
94
- it("should render boolean exclusiveMinimum", () => {
95
- const expected = "**Possible values:** `> 1`";
96
- const actual = getQualifierMessage({ minimum: 1, exclusiveMinimum: true });
97
- expect(actual).toBe(expected);
98
- });
99
-
100
- it("should render boolean exclusiveMaximum", () => {
101
- const expected = "**Possible values:** `< 40`";
102
- const actual = getQualifierMessage({ maximum: 40, exclusiveMaximum: true });
103
- expect(actual).toBe(expected);
104
- });
105
-
106
- it("should render minimum when exclusiveMinimum is false", () => {
107
- const expected = "**Possible values:** `>= 1`";
108
- const actual = getQualifierMessage({ minimum: 1, exclusiveMinimum: false });
109
- expect(actual).toBe(expected);
110
- });
111
-
112
- it("should render maximum when exclusiveMaximum is false", () => {
113
- const expected = "**Possible values:** `<= 40`";
114
- const actual = getQualifierMessage({
115
- maximum: 40,
116
- exclusiveMaximum: false,
117
- });
118
- expect(actual).toBe(expected);
119
- });
120
-
121
- it("should render minimum and maximum", () => {
122
- const expected = "**Possible values:** `>= 1` and `<= 40`";
123
- const actual = getQualifierMessage({ minimum: 1, maximum: 40 });
124
- expect(actual).toBe(expected);
125
- });
126
-
127
- it("should render 0 minimum and maximum", () => {
128
- const expected = "**Possible values:** `>= 0` and `<= 40`";
129
- const actual = getQualifierMessage({ minimum: 0, maximum: 40 });
130
- expect(actual).toBe(expected);
131
- });
132
-
133
- it("should render minimum and 0 maximum", () => {
134
- const expected = "**Possible values:** `>= -10` and `<= 0`";
135
- const actual = getQualifierMessage({ minimum: -10, maximum: 0 });
136
- expect(actual).toBe(expected);
137
- });
138
-
139
- it("should render boolean exclusiveMinimum and maximum", () => {
140
- const expected = "**Possible values:** `> 1` and `<= 40`";
141
- const actual = getQualifierMessage({
142
- minimum: 1,
143
- maximum: 40,
144
- exclusiveMinimum: true,
145
- });
146
- expect(actual).toBe(expected);
147
- });
148
-
149
- it("should render minimum and boolean exclusiveMaximum", () => {
150
- const expected = "**Possible values:** `>= 1` and `< 40`";
151
- const actual = getQualifierMessage({
152
- minimum: 1,
153
- maximum: 40,
154
- exclusiveMaximum: true,
155
- });
156
- expect(actual).toBe(expected);
157
- });
158
-
159
- it("should render numeric exclusiveMinimum and maximum", () => {
160
- const expected = "**Possible values:** `> 1` and `<= 40`";
161
- const actual = getQualifierMessage({
162
- exclusiveMinimum: 1,
163
- maximum: 40,
164
- });
165
- expect(actual).toBe(expected);
166
- });
167
-
168
- it("should render minimum and numeric exclusiveMaximum", () => {
169
- const expected = "**Possible values:** `>= 1` and `< 40`";
170
- const actual = getQualifierMessage({
171
- minimum: 1,
172
- exclusiveMaximum: 40,
173
- });
174
- expect(actual).toBe(expected);
175
- });
176
-
177
- it("should render numeric exclusiveMinimum and boolean exclusiveMaximum", () => {
178
- const expected = "**Possible values:** `> 1` and `< 40`";
179
- const actual = getQualifierMessage({
180
- exclusiveMinimum: 1,
181
- maximum: 40,
182
- exclusiveMaximum: true,
183
- });
184
- expect(actual).toBe(expected);
185
- });
186
-
187
- it("should render nothing with empty boolean exclusiveMinimum", () => {
188
- const actual = getQualifierMessage({
189
- exclusiveMinimum: true,
190
- });
191
- expect(actual).toBeUndefined();
192
- });
193
-
194
- it("should render nothing with empty boolean exclusiveMaximum", () => {
195
- const actual = getQualifierMessage({
196
- exclusiveMaximum: true,
197
- });
198
- expect(actual).toBeUndefined();
199
- });
200
-
201
- it("should render nothing with empty boolean exclusiveMinimum and exclusiveMaximum", () => {
202
- const actual = getQualifierMessage({
203
- exclusiveMinimum: true,
204
- exclusiveMaximum: true,
205
- });
206
- expect(actual).toBeUndefined();
207
- });
208
- });