@@ -26,6 +26,24 @@ describe('Core Functions / Xor', () => {
2626 ] ) ;
2727 } ) ;
2828
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+
2947 it ( 'given both properties, should return an error message' , async ( ) => {
3048 expect (
3149 await runXor (
@@ -99,22 +117,12 @@ describe('Core Functions / Xor', () => {
99117 ] ) ,
100118 ] ,
101119 ] ,
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- ] ,
112120 [
113121 { properties : [ 'foo' , { } ] } ,
114122 [
115123 new RulesetValidationError (
116124 '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"]' ,
118126 [ 'rules' , 'my-rule' , 'then' , 'functionOptions' , 'properties' ] ,
119127 ) ,
120128 ] ,
@@ -124,7 +132,7 @@ describe('Core Functions / Xor', () => {
124132 [
125133 new RulesetValidationError (
126134 '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"]' ,
128136 [ 'rules' , 'my-rule' , 'then' , 'functionOptions' , 'properties' ] ,
129137 ) ,
130138 ] ,
@@ -134,7 +142,7 @@ describe('Core Functions / Xor', () => {
134142 [
135143 new RulesetValidationError (
136144 '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"]' ,
138146 [ 'rules' , 'my-rule' , 'then' , 'functionOptions' , 'properties' ] ,
139147 ) ,
140148 ] ,
0 commit comments