-
-
Notifications
You must be signed in to change notification settings - Fork 864
/
1935_integer_narrowing_subschema.spec.ts
111 lines (103 loc) · 2.06 KB
/
1935_integer_narrowing_subschema.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import _Ajv from "../ajv"
import Ajv from "ajv"
import * as assert from "assert"
describe("integer valid type in number sub-schema (issue #1935)", () => {
let ajv: Ajv
before(() => {
ajv = new _Ajv({strict: true})
})
it("should allow integer in `if`", () =>
assert.doesNotThrow(() =>
ajv.compile({
type: "number",
if: {
type: "integer",
maximum: 5,
},
else: {
minimum: 10,
},
})
))
it("should allow integer in `then`", () =>
assert.doesNotThrow(() =>
ajv.compile({
type: "number",
if: {
multipleOf: 2,
},
then: {
type: "integer",
minimum: 10,
},
})
))
it("should allow integer in `else`", () =>
assert.doesNotThrow(() =>
ajv.compile({
type: "number",
if: {
maximum: 5,
},
else: {
type: "integer",
minimum: 10,
},
})
))
it("should allow integer in `allOf`", () =>
assert.doesNotThrow(() =>
ajv.compile({
type: "number",
allOf: [
{
type: "integer",
minimum: 10,
},
{
multipleOf: 2,
},
],
})
))
it("should allow integer in `oneOf`", () =>
assert.doesNotThrow(() =>
ajv.compile({
type: "number",
oneOf: [
{
type: "integer",
minimum: 10,
},
{
multipleOf: 2,
},
],
})
))
it("should allow integer in `anyOf`", () =>
assert.doesNotThrow(() =>
ajv.compile({
type: "number",
oneOf: [
{
type: "integer",
minimum: 10,
},
{
multipleOf: 2,
},
],
})
))
it("should allow integer in `not`", () =>
assert.doesNotThrow(() =>
ajv.compile({
type: "number",
not: {
type: "integer",
minimum: 10,
},
})
))
})