Skip to content

Commit 84988b1

Browse files
authored
test(pagination): fix new tests in CI (2)
1 parent 671a6f5 commit 84988b1

File tree

1 file changed

+26
-19
lines changed

1 file changed

+26
-19
lines changed

packages/openapi-ts/src/ir/__tests__/pagination.test.ts

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ describe('operationPagination', () => {
8080
type: IR.SchemaObject['type'] = 'string',
8181
pagination = false,
8282
): IR.ParameterObject => ({
83-
name,
83+
explode: true,
8484
location: 'query',
85+
name,
8586
schema: { type },
8687
style: 'form',
87-
explode: true,
8888
...(pagination ? { pagination: true } : {}),
8989
});
9090

@@ -129,7 +129,13 @@ describe('operationPagination', () => {
129129

130130
it.each(queryScenarios)(
131131
'query params for $operation.id → $hasPagination',
132-
({ hasPagination, operation }: { hasPagination: boolean; operation: IR.OperationObject }) => {
132+
({
133+
hasPagination,
134+
operation,
135+
}: {
136+
hasPagination: boolean;
137+
operation: IR.OperationObject;
138+
}) => {
133139
const result = operationPagination({ context: emptyContext, operation });
134140
expect(Boolean(result)).toEqual(hasPagination);
135141
},
@@ -138,17 +144,17 @@ describe('operationPagination', () => {
138144
it('body.pagination === true returns entire body', () => {
139145
const operation: IR.OperationObject = {
140146
...baseOperationMeta,
141-
id: 'bodyTrue',
142147
body: {
143148
mediaType: 'application/json',
144149
pagination: true,
145150
schema: {
146-
type: 'object',
147151
properties: {
148152
page: { type: 'integer' },
149153
},
154+
type: 'object',
150155
},
151156
},
157+
id: 'bodyTrue',
152158
};
153159

154160
const result = operationPagination({ context: emptyContext, operation });
@@ -161,22 +167,22 @@ describe('operationPagination', () => {
161167
it('body.pagination = "pagination" returns the matching property', () => {
162168
const operation: IR.OperationObject = {
163169
...baseOperationMeta,
164-
id: 'bodyField',
165170
body: {
166171
mediaType: 'application/json',
167172
pagination: 'pagination',
168173
schema: {
169-
type: 'object',
170174
properties: {
171175
pagination: {
172-
type: 'object',
173176
properties: {
174177
page: { type: 'integer' },
175178
},
179+
type: 'object',
176180
},
177181
},
182+
type: 'object',
178183
},
179184
},
185+
id: 'bodyField',
180186
};
181187

182188
const result = operationPagination({ context: emptyContext, operation });
@@ -189,26 +195,26 @@ describe('operationPagination', () => {
189195
it('resolves $ref and uses the resolved pagination property', () => {
190196
const context: IR.Context = {
191197
resolveIrRef: vi.fn().mockReturnValue({
192-
type: 'object',
193198
properties: {
194199
pagination: {
195-
type: 'object',
196200
properties: {
197201
page: { type: 'integer' },
198202
},
203+
type: 'object',
199204
},
200205
},
206+
type: 'object',
201207
}),
202208
} as unknown as IR.Context;
203209

204210
const operation: IR.OperationObject = {
205211
...baseOperationMeta,
206-
id: 'refPagination',
207212
body: {
208213
mediaType: 'application/json',
209214
pagination: 'pagination',
210215
schema: { $ref: '#/components/schemas/PaginationBody' },
211216
},
217+
id: 'refPagination',
212218
};
213219

214220
const result = operationPagination({ context, operation });
@@ -224,20 +230,20 @@ describe('operationPagination', () => {
224230
it('falls back to query when pagination key not found in body', () => {
225231
const operation: IR.OperationObject = {
226232
...baseOperationMeta,
227-
id: 'fallback',
228-
parameters: {
229-
query: {
230-
cursor: queryParam('cursor', 'string', true),
231-
},
232-
},
233233
body: {
234234
mediaType: 'application/json',
235235
pagination: 'pagination',
236236
schema: {
237-
type: 'object',
238237
properties: {
239238
notPagination: { type: 'string' },
240239
},
240+
type: 'object',
241+
},
242+
},
243+
id: 'fallback',
244+
parameters: {
245+
query: {
246+
cursor: queryParam('cursor', 'string', true),
241247
},
242248
},
243249
};
@@ -248,4 +254,5 @@ describe('operationPagination', () => {
248254
expect(result?.name).toEqual('cursor');
249255
expect(result?.schema?.type).toEqual('string');
250256
});
251-
});
257+
});
258+
test(pagination): fix new tests in CI (2)

0 commit comments

Comments
 (0)