@@ -42,12 +42,36 @@ describe('evaluate visibility expression', () => {
4242 expect ( console . warn ) . not . toHaveBeenCalled ( ) ;
4343 } ) ;
4444
45- test ( 'warns and falls back to default for invalid expression' , ( ) => {
45+ test ( 'falls back to default for invalid expression with zoom' , ( ) => {
46+ const value = createVisibilityExpression ( [ 'case' , [ '==' , [ 'zoom' ] , 5 ] , 'none' , 'visible' ] , { } ) ;
47+
48+ vi . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
49+
50+ expect ( value . evaluate ( {
51+ zoom : 5
52+ } ) ) . toBe ( 'visible' ) ;
53+ expect ( console . warn ) . not . toHaveBeenCalled ( ) ;
54+ } ) ;
55+
56+ test ( 'warns and falls back to default for invalid expression with feature' , ( ) => {
4657 const value = createVisibilityExpression ( [ 'get' , 'x' ] , { } ) ;
4758
4859 vi . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
4960
50- expect ( value . evaluate ( ) ) . toBe ( 'visible' ) ;
61+ expect ( value . evaluate ( {
62+ properties : { x : 'none' }
63+ } ) ) . toBe ( 'visible' ) ;
64+ expect ( console . warn ) . toHaveBeenCalledWith ( 'Expected value to be of type string, but found null instead.' ) ;
65+ } ) ;
66+
67+ test ( 'warns and falls back to default for invalid expression with feature state' , ( ) => {
68+ const value = createVisibilityExpression ( [ 'feature-state' , 'x' ] , { } ) ;
69+
70+ vi . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
71+
72+ expect ( value . evaluate ( {
73+ x : 'none'
74+ } ) ) . toBe ( 'visible' ) ;
5175 expect ( console . warn ) . toHaveBeenCalledWith ( 'Expected value to be of type string, but found null instead.' ) ;
5276 } ) ;
5377
0 commit comments