Files
swagger-ui/test/unit/core/plugins/oas31/fn.js
kyy f464ba2d31
Some checks failed
Node.js CI / build (push) Failing after 2s
Node.js CI / e2e-tests (+(a11y|security|bugs)/**/*cy.js) (push) Failing after 2s
Node.js CI / e2e-tests (features/**/!(o|d|m)*.cy.js) (push) Failing after 2s
Node.js CI / e2e-tests (features/**/+(o|d)*.cy.js) (push) Failing after 2s
Node.js CI / e2e-tests (features/**/m*.cy.js) (push) Failing after 2s
CodeQL / Analyze (javascript) (push) Failing after 2m49s
Security scan for docker image / build (push) Failing after 54s
Update swagger-ui
2025-06-24 13:40:26 +09:00

38 lines
1.2 KiB
JavaScript
Executable File

import { fromJS } from "immutable"
import { isOAS31 } from "core/plugins/oas31/fn"
const isOAS31Shorthand = (version) => isOAS31(fromJS({
openapi: version
}))
describe("isOAS30", function () {
it("should recognize valid OAS3 version values", function () {
expect(isOAS31Shorthand("3.1.0")).toEqual(true)
expect(isOAS31Shorthand("3.1.1")).toEqual(true)
expect(isOAS31Shorthand("3.1.25")).toEqual(true)
})
it("should fail for invalid OAS3 version values", function () {
expect(isOAS31Shorthand("3.1")).toEqual(false)
expect(isOAS31Shorthand("3.1.")).toEqual(false)
expect(isOAS31Shorthand("3.1.01")).toEqual(false)
expect(isOAS31Shorthand("2.0")).toEqual(false)
})
it("should gracefully fail for non-string values", function () {
expect(isOAS31Shorthand(3.0)).toEqual(false)
expect(isOAS31Shorthand(3)).toEqual(false)
expect(isOAS31Shorthand({})).toEqual(false)
expect(isOAS31Shorthand(null)).toEqual(false)
})
it("should gracefully fail when `openapi` field is missing", function () {
expect(isOAS31(fromJS({
openApi: "3.1.0"
}))).toEqual(false)
expect(isOAS31Shorthand(null)).toEqual(false)
})
})