@@ -164,6 +164,17 @@ describe('filter', () => {
164164 } ) ;
165165
166166 describe ( 'logical operators' , ( ) => {
167+ it ( 'should handle simple logical operators (not)' , ( ) => {
168+ const filter = {
169+ not : { FooProp : { startswith : 'foo' } }
170+ } ;
171+ const expected =
172+ "?$filter=not (startswith(FooProp,'foo'))" ;
173+ const actual = buildQuery ( { filter } ) ;
174+ expect ( actual ) . toEqual ( expected ) ;
175+ } ) ;
176+
177+
167178 it ( 'should handle simple logical operators (not) as an object' , ( ) => {
168179 const filter = {
169180 and : [
@@ -173,7 +184,24 @@ describe('filter', () => {
173184 ] ,
174185 } ;
175186 const expected =
176- "?$filter=((not (startswith(FooProp,'foo'))) and (not (startswith(BarProp,'bar'))) and (startswith(FooBarProp,'foobar')))" ;
187+ "?$filter=((not (startswith(FooProp,'foo'))) and (not (startswith(BarProp,'bar'))) and (startswith(FooBarProp,'foobar')))" ;
188+ const actual = buildQuery ( { filter } ) ;
189+ expect ( actual ) . toEqual ( expected ) ;
190+ } ) ;
191+
192+ it ( 'should handle simple logical operators (not) inside nested prop' , ( ) => {
193+ const filter = {
194+ Prop : {
195+ all : {
196+ and : [
197+ { not : { FooProp : { contains : "foo" } } } ,
198+ { BarProp : { contains : "bar" } } ,
199+ ] ,
200+ } ,
201+ } ,
202+ } ;
203+ const expected =
204+ "?$filter=Prop/all(prop:((not (contains(prop/FooProp,'foo'))) and (contains(prop/BarProp,'bar'))))" ;
177205 const actual = buildQuery ( { filter } ) ;
178206 expect ( actual ) . toEqual ( expected ) ;
179207 } ) ;
0 commit comments