import test from 'unit.js' ; import { OptionalPropertyValue , NullablePropertyValue , PropertyValue } from '../filters' ; describe ( 'Test Filters' , ( ) => { it ( 'Test Scalar PropertyValue' , async ( ) => { const filter = PropertyValue ( 'property' , 'scalar' ) ; test . object ( filter ) . hasProperty ( 'property' ) ; test . object ( filter . property ) . hasProperty ( '_type' , 'equal' ) ; test . object ( filter . property ) . hasProperty ( 'value' , 'scalar' ) ; } ) ; it ( 'Test Array PropertyValue' , async ( ) => { const filter = PropertyValue ( 'property' , [ 'array' ] ) ; test . object ( filter ) . hasProperty ( 'property' ) ; test . object ( filter . property ) . hasProperty ( '_type' , 'in' ) ; test . object ( filter . property ) . hasProperty ( 'value' ) ; test . value ( filter . property ?. value ) . is ( [ 'array' ] ) ; } ) ; it ( 'Test NullablePropertyValue (null)' , async ( ) => { const filter = NullablePropertyValue ( 'property' , null ) ; test . object ( filter ) . hasProperty ( 'property' ) ; test . object ( filter . property ) . hasProperty ( '_type' , 'isNull' ) ; } ) ; it ( 'Test NullablePropertyValue (value)' , async ( ) => { const filter = NullablePropertyValue ( 'property' , 'scalar' ) ; test . object ( filter ) . hasProperty ( 'property' ) ; test . object ( filter . property ) . hasProperty ( '_type' , 'equal' ) ; test . object ( filter . property ) . hasProperty ( 'value' , 'scalar' ) ; } ) ; it ( 'Test OptionalPropertyValue (undefined)' , async ( ) => { const filter = OptionalPropertyValue ( NullablePropertyValue , 'property' , undefined ) ; test . value ( filter ) . is ( { } ) ; } ) ; it ( 'Test OptionalPropertyValue (null)' , async ( ) => { const filter = OptionalPropertyValue ( NullablePropertyValue , 'property' , null ) ; test . object ( filter ) . hasProperty ( 'property' ) ; test . object ( filter . property ) . hasProperty ( '_type' , 'isNull' ) ; } ) ; } ) ;