fix(json-schema-2020-12-samples): fix constraints for integer example values (#9749)

Refs #9740
This commit is contained in:
Oliwia Rogala
2024-03-26 14:55:25 +01:00
committed by GitHub
parent a82f6448d4
commit c002e59791
3 changed files with 68 additions and 8 deletions

View File

@@ -1646,7 +1646,7 @@ describe("sampleFromSchema", () => {
expect(sampleFromSchema(definition)).toEqual(expected)
})
it("should handle minimum", () => {
it("should handle minimum for number", () => {
const definition = {
type: "number",
minimum: 5,
@@ -1657,7 +1657,7 @@ describe("sampleFromSchema", () => {
expect(sampleFromSchema(definition)).toEqual(expected)
})
it("should handle exclusiveMinimum", () => {
it("should handle exclusiveMinimum for number", () => {
const definition = {
type: "number",
exclusiveMinimum: 5,
@@ -1667,7 +1667,7 @@ describe("sampleFromSchema", () => {
expect(sampleFromSchema(definition)).toEqual(expected)
})
it("should handle maximum", () => {
it("should handle maximum for number", () => {
const definition = {
type: "number",
maximum: -1,
@@ -1678,7 +1678,7 @@ describe("sampleFromSchema", () => {
expect(sampleFromSchema(definition)).toEqual(expected)
})
it("should handle exclusiveMaximum", () => {
it("should handle exclusiveMaximum for number", () => {
const definition = {
type: "number",
exclusiveMaximum: -1,
@@ -1689,7 +1689,7 @@ describe("sampleFromSchema", () => {
expect(sampleFromSchema(definition)).toEqual(expected)
})
it("should handle multipleOf", () => {
it("should handle multipleOf for number", () => {
const definition = {
type: "number",
minimum: 22,
@@ -1701,6 +1701,61 @@ describe("sampleFromSchema", () => {
expect(sampleFromSchema(definition)).toStrictEqual(expected)
})
it("should handle minimum for integer", () => {
const definition = {
type: "integer",
minimum: 5,
}
const expected = 5
expect(sampleFromSchema(definition)).toEqual(expected)
})
it("should handle exclusiveMinimum for integer", () => {
const definition = {
type: "integer",
exclusiveMinimum: 5,
}
const expected = 6
expect(sampleFromSchema(definition)).toEqual(expected)
})
it("should handle maximum for integer", () => {
const definition = {
type: "integer",
maximum: -1,
}
const expected = -1
expect(sampleFromSchema(definition)).toEqual(expected)
})
it("should handle exclusiveMaximum for integer", () => {
const definition = {
type: "integer",
exclusiveMaximum: -1,
}
const expected = -2
expect(sampleFromSchema(definition)).toEqual(expected)
})
it("should handle multipleOf for integer", () => {
const definition = {
type: "integer",
minimum: 22,
multipleOf: 3,
}
const expected = 24
expect(sampleFromSchema(definition)).toStrictEqual(expected)
})
it("should handle minLength", () => {
const definition = {
type: "string",