UNPKG

@apistudio/apim-cli

Version:

CLI for API Management Products

51 lines (40 loc) 1.24 kB
/** * Copyright Super iPaaS Integration LLC, an IBM Company 2024 */ import { isValidRestAPI } from "./rest-api-validation-helper"; import { BaseAsset } from "../../model/assets-model"; // Define mock data const openAPIExample = { openapi: "3.0.0", paths: {}, }; const swaggerAPIExample = { swagger: "2.0", paths: {}, }; const invalidAPIExample = { invalidField: "value", }; const notAnObject = "string"; const emptyObject = {}; describe("isValidRestAPI", () => { it("should return true for a valid OpenAPI object", () => { expect(isValidRestAPI(openAPIExample as unknown as BaseAsset)).toBe(true); }); it("should return true for a valid Swagger API object", () => { expect(isValidRestAPI(swaggerAPIExample as unknown as BaseAsset)).toBe( true ); }); it("should return false for an invalid API object", () => { expect(isValidRestAPI(invalidAPIExample as unknown as BaseAsset)).toBe( false ); }); it("should return false for a non-object input", () => { expect(isValidRestAPI(notAnObject as unknown as BaseAsset)).toBe(false); }); it("should return false for an empty object", () => { expect(isValidRestAPI(emptyObject as BaseAsset)).toBe(false); }); });