UNPKG

docusaurus-plugin-openapi-docs

Version:

OpenAPI plugin for Docusaurus.

49 lines (48 loc) 1.9 kB
"use strict"; /* ============================================================================ * Copyright (c) Palo Alto Networks * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * ========================================================================== */ Object.defineProperty(exports, "__esModule", { value: true }); const createSchemaExample_1 = require("./createSchemaExample"); describe("sampleFromSchema", () => { describe("const support", () => { it("should return default string value when const is not present", () => { const schema = { type: "string", }; const context = { type: "request" }; const result = (0, createSchemaExample_1.sampleFromSchema)(schema, context); expect(result).toBe("string"); }); it("should return const value when const is present", () => { const schema = { type: "string", const: "example", }; const context = { type: "request" }; const result = (0, createSchemaExample_1.sampleFromSchema)(schema, context); expect(result).toBe("example"); }); it("should handle anyOf with const values", () => { const schema = { type: "string", anyOf: [ { type: "string", const: "dog", }, { type: "string", const: "cat", }, ], }; const context = { type: "request" }; const result = (0, createSchemaExample_1.sampleFromSchema)(schema, context); expect(result).toBe("dog"); }); }); });