Skip to content

Commit ae06513

Browse files
authored
Merge pull request #593 from json-schema-org/gregsdennis-propertyDependencies-tests
propertyDependencies tests
2 parents 6eaf7df + 0ba0976 commit ae06513

File tree

1 file changed

+161
-0
lines changed

1 file changed

+161
-0
lines changed
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
[
2+
{
3+
"description": "propertyDependencies doesn't act on non-objects",
4+
"schema": {
5+
"propertyDependencies": {
6+
"foo": {"bar": false}
7+
}
8+
},
9+
"tests": [
10+
{
11+
"description": "ignores booleans",
12+
"data": true,
13+
"valid": true
14+
},
15+
{
16+
"description": "ignores integers",
17+
"data": 123,
18+
"valid": true
19+
},
20+
{
21+
"description": "ignores floats",
22+
"data": 1.0,
23+
"valid": true
24+
},
25+
{
26+
"description": "ignores strings",
27+
"data": "abc",
28+
"valid": true
29+
},
30+
{
31+
"description": "ignores arrays",
32+
"data": [],
33+
"valid": true
34+
},
35+
{
36+
"description": "ignores null",
37+
"data": null,
38+
"valid": true
39+
}
40+
]
41+
},
42+
{
43+
"description": "propertyDependencies doesn't act on non-string property values",
44+
"schema": {
45+
"propertyDependencies": {
46+
"foo": {"bar": false}
47+
}
48+
},
49+
"tests": [
50+
{
51+
"description": "ignores booleans",
52+
"data": {"foo": false},
53+
"valid": true
54+
},
55+
{
56+
"description": "ignores integers",
57+
"data": {"foo": 2},
58+
"valid": true
59+
},
60+
{
61+
"description": "ignores floats",
62+
"data": {"foo": 1.1},
63+
"valid": true
64+
},
65+
{
66+
"description": "ignores objects",
67+
"data": {"foo": {}},
68+
"valid": true
69+
},
70+
{
71+
"description": "ignores objects wth a key of the expected value",
72+
"data": {"foo": {"bar": "baz"}},
73+
"valid": true
74+
},
75+
{
76+
"description": "ignores objects with the expected value nested in structure",
77+
"data": {"foo": {"baz": "bar"}},
78+
"valid": true
79+
},
80+
{
81+
"description": "ignores arrays",
82+
"data": {"foo": []},
83+
"valid": true
84+
},
85+
{
86+
"description": "ignores null",
87+
"data": {"foo": null},
88+
"valid": true
89+
}
90+
]
91+
},
92+
{
93+
"description": "multiple options selects the right one",
94+
"schema": {
95+
"propertyDependencies": {
96+
"foo": {
97+
"bar": {
98+
"minProperties": 2,
99+
"maxProperties": 2
100+
},
101+
"baz": {"maxProperties": 1},
102+
"qux": true,
103+
"quux": false
104+
}
105+
}
106+
},
107+
"tests": [
108+
{
109+
"description": "bar with exactly 2 properties is valid",
110+
"data": {
111+
"foo": "bar",
112+
"other-foo": "other-bar"
113+
},
114+
"valid": true
115+
},
116+
{
117+
"description": "bar with more than 2 properties is invalid",
118+
"data": {
119+
"foo": "bar",
120+
"other-foo": "other-bar",
121+
"too": "many"
122+
},
123+
"valid": false
124+
},
125+
{
126+
"description": "bar with fewer than 2 properties is invalid",
127+
"data": {"foo": "bar"},
128+
"valid": false
129+
},
130+
{
131+
"description": "baz alone is valid",
132+
"data": {"foo": "baz"},
133+
"valid": true
134+
},
135+
{
136+
"description": "baz with other properties is invalid",
137+
"data": {
138+
"foo": "baz",
139+
"other-foo": "other-bar"
140+
},
141+
"valid": false
142+
},
143+
{
144+
"description": "anything allowed with qux",
145+
"data": {
146+
"foo": "qux",
147+
"blah": ["some other property"],
148+
"more": "properties"
149+
},
150+
"valid": true
151+
},
152+
{
153+
"description": "quux is disallowed",
154+
"data": {
155+
"foo": "quux"
156+
},
157+
"valid": false
158+
}
159+
]
160+
}
161+
]

0 commit comments

Comments
 (0)