|
1 |
| -import { comment, escObjKey, getSchemaObjectComment, parseRef, tsIntersectionOf, tsUnionOf } from "../src/utils.js"; |
| 1 | +import { ParameterObject, ReferenceObject } from "../src/types.js"; |
| 2 | +import { comment, escObjKey, getParametersArray, getSchemaObjectComment, parseRef, tsIntersectionOf, tsUnionOf } from "../src/utils.js"; |
2 | 3 |
|
3 | 4 | describe("utils", () => {
|
4 | 5 | describe("tsUnionOf", () => {
|
@@ -167,4 +168,25 @@ describe("utils", () => {
|
167 | 168 | );
|
168 | 169 | });
|
169 | 170 | });
|
| 171 | + |
| 172 | + describe('getParametersArray', () => { |
| 173 | + it('should return an empty array if no parameters are passed', () => { |
| 174 | + expect(getParametersArray()).toEqual([]); |
| 175 | + }); |
| 176 | + |
| 177 | + it('should return an array if a single parameter is passed', () => { |
| 178 | + const parameter: ParameterObject = { name: 'test', in: 'query' }; |
| 179 | + expect(getParametersArray(parameter)).toEqual([parameter]); |
| 180 | + }); |
| 181 | + |
| 182 | + it('should return an array if an array of parameters is passed', () => { |
| 183 | + const parameters: ParameterObject[] = [{ name: 'test', in: 'query' }, { name: 'test2', in: 'query' }]; |
| 184 | + expect(getParametersArray(parameters)).toEqual(parameters); |
| 185 | + }); |
| 186 | + |
| 187 | + it('should return an array if an array of references is passed', () => { |
| 188 | + const references: ReferenceObject[] = [{ $ref: 'test' }, { $ref: 'test2' }]; |
| 189 | + expect(getParametersArray(references)).toEqual(references); |
| 190 | + }); |
| 191 | + }); |
170 | 192 | });
|
0 commit comments