UNPKG

openapi-codegen-typescript

Version:

OpenApi codegen for generating types an mocks from swagger json file

68 lines (67 loc) 3.26 kB
"use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); var getResultStringForArrayType_1 = require("./getResultStringForArrayType"); var defaultProps = { propertyName: 'propertyName mocked', description: 'description mocked', nullable: true, refType: ['path', 'refType mocked'], format: 'format mocked', minItems: 1, maxItems: 10, uniqueItems: true, }; var scenarios = [ { input: __assign(__assign({}, defaultProps), { description: 'description mocked' }), output: "/**\n * description mocked\n */\n\tpropertyName mocked?: refType mocked[]; // format: \"format mocked\"; minItems: 1; maxItems: 10; uniqueItems: true\n", }, { input: __assign(__assign({}, defaultProps), { description: undefined }), output: "\tpropertyName mocked?: refType mocked[]; // format: \"format mocked\"; minItems: 1; maxItems: 10; uniqueItems: true\n", }, { input: __assign(__assign({}, defaultProps), { minItems: undefined }), output: "/**\n * description mocked\n */\n\tpropertyName mocked?: refType mocked[]; // format: \"format mocked\"; maxItems: 10; uniqueItems: true\n", }, { input: __assign(__assign({}, defaultProps), { maxItems: undefined }), output: "/**\n * description mocked\n */\n\tpropertyName mocked?: refType mocked[]; // format: \"format mocked\"; minItems: 1; uniqueItems: true\n", }, { input: __assign(__assign({}, defaultProps), { format: undefined }), output: "/**\n * description mocked\n */\n\tpropertyName mocked?: refType mocked[]; // minItems: 1; maxItems: 10; uniqueItems: true\n", }, { input: __assign(__assign({}, defaultProps), { uniqueItems: false }), output: "/**\n * description mocked\n */\n\tpropertyName mocked?: refType mocked[]; // format: \"format mocked\"; minItems: 1; maxItems: 10\n", }, { input: __assign(__assign({}, defaultProps), { format: undefined, minItems: undefined }), output: "/**\n * description mocked\n */\n\tpropertyName mocked?: refType mocked[]; // maxItems: 10; uniqueItems: true\n", }, { input: __assign(__assign({}, defaultProps), { format: undefined, minItems: undefined, maxItems: undefined }), output: "/**\n * description mocked\n */\n\tpropertyName mocked?: refType mocked[]; // uniqueItems: true\n", }, { input: __assign(__assign({}, defaultProps), { format: undefined, minItems: undefined, maxItems: undefined, uniqueItems: false }), output: "/**\n * description mocked\n */\n\tpropertyName mocked?: refType mocked[];\n", }, ]; it.each(scenarios)("should return expected string", function (_a) { var input = _a.input, output = _a.output; var result = getResultStringForArrayType_1.getResultStringForArrayType(input); expect(result).toBe(output); });