@@ -26,6 +26,24 @@ describe('Core Functions / Xor', () => {
26
26
] ) ;
27
27
} ) ;
28
28
29
+ it ( 'given multiple properties that do not match, should return an error message' , async ( ) => {
30
+ expect (
31
+ await runXor (
32
+ {
33
+ version : '1.0.0' ,
34
+ title : 'Swagger Petstore' ,
35
+ termsOfService : 'http://swagger.io/terms/' ,
36
+ } ,
37
+ { properties : [ 'yada-yada' , 'whatever' , 'foo' ] } ,
38
+ ) ,
39
+ ) . toEqual ( [
40
+ {
41
+ message : '"yada-yada", "whatever" and "foo" must not be both defined or both undefined' ,
42
+ path : [ ] ,
43
+ } ,
44
+ ] ) ;
45
+ } ) ;
46
+
29
47
it ( 'given both properties, should return an error message' , async ( ) => {
30
48
expect (
31
49
await runXor (
@@ -99,22 +117,12 @@ describe('Core Functions / Xor', () => {
99
117
] ) ,
100
118
] ,
101
119
] ,
102
- [
103
- { properties : [ 'foo' , 'bar' , 'baz' ] } ,
104
- [
105
- new RulesetValidationError (
106
- 'invalid-function-options' ,
107
- '"xor" and its "properties" option support 2-item tuples, i.e. ["id", "name"]' ,
108
- [ 'rules' , 'my-rule' , 'then' , 'functionOptions' , 'properties' ] ,
109
- ) ,
110
- ] ,
111
- ] ,
112
120
[
113
121
{ properties : [ 'foo' , { } ] } ,
114
122
[
115
123
new RulesetValidationError (
116
124
'invalid-function-options' ,
117
- '"xor" and its "properties" option support 2-item tuples, i.e. ["id", "name"]' ,
125
+ '"xor" and its "properties" option require at least 2-item tuples, i.e. ["id", "name"]' ,
118
126
[ 'rules' , 'my-rule' , 'then' , 'functionOptions' , 'properties' ] ,
119
127
) ,
120
128
] ,
@@ -124,7 +132,7 @@ describe('Core Functions / Xor', () => {
124
132
[
125
133
new RulesetValidationError (
126
134
'invalid-function-options' ,
127
- '"xor" and its "properties" option support 2-item tuples, i.e. ["id", "name"]' ,
135
+ '"xor" and its "properties" option require at least 2-item tuples, i.e. ["id", "name"]' ,
128
136
[ 'rules' , 'my-rule' , 'then' , 'functionOptions' , 'properties' ] ,
129
137
) ,
130
138
] ,
@@ -134,7 +142,7 @@ describe('Core Functions / Xor', () => {
134
142
[
135
143
new RulesetValidationError (
136
144
'invalid-function-options' ,
137
- '"xor" and its "properties" option support 2-item tuples, i.e. ["id", "name"]' ,
145
+ '"xor" and its "properties" option require at least 2-item tuples, i.e. ["id", "name"]' ,
138
146
[ 'rules' , 'my-rule' , 'then' , 'functionOptions' , 'properties' ] ,
139
147
) ,
140
148
] ,
0 commit comments