@@ -146,6 +146,52 @@ describe('Grid properties', () => {
146146 expect ( TDD . rows . first . data . id ) . to . equal ( 8 ) ;
147147 } ) ;
148148
149+ it ( 'Sort expressions late binding replaces previous state' , async ( ) => {
150+ await TDD . updateProperty ( 'sortingExpressions' , [ { key : 'id' , direction : 'descending' } ] ) ;
151+ expect ( TDD . grid . sortingExpressions ) . lengthOf ( 1 ) ;
152+ expect ( TDD . rows . first . data . id ) . to . equal ( 8 ) ;
153+
154+ await TDD . updateProperty ( 'sortingExpressions' , [ { key : 'name' , direction : 'ascending' } ] ) ;
155+ expect ( TDD . grid . sortingExpressions ) . lengthOf ( 1 ) ;
156+ expect ( TDD . grid . sortingExpressions [ 0 ] . key ) . to . equal ( 'name' ) ;
157+ } ) ;
158+
159+ it ( 'Sort expressions late binding clears state with empty array' , async ( ) => {
160+ await TDD . updateProperty ( 'sortingExpressions' , [ { key : 'id' , direction : 'descending' } ] ) ;
161+ expect ( TDD . grid . sortingExpressions ) . lengthOf ( 1 ) ;
162+
163+ await TDD . updateProperty ( 'sortingExpressions' , [ ] ) ;
164+ expect ( TDD . grid . sortingExpressions ) . lengthOf ( 0 ) ;
165+ } ) ;
166+
167+ it ( 'Filter expressions late binding replaces previous state' , async ( ) => {
168+ await TDD . updateColumns ( { field : 'id' , dataType : 'number' } ) ;
169+ await TDD . updateProperty ( 'filterExpressions' , [
170+ { key : 'id' , condition : 'greaterThanOrEqual' , searchTerm : 8 } ,
171+ ] ) ;
172+ expect ( TDD . grid . filterExpressions ) . lengthOf ( 1 ) ;
173+ expect ( TDD . grid . totalItems ) . to . equal ( 1 ) ;
174+
175+ await TDD . updateProperty ( 'filterExpressions' , [
176+ { key : 'name' , condition : 'startsWith' , searchTerm : 'A' } ,
177+ ] ) ;
178+ expect ( TDD . grid . filterExpressions ) . lengthOf ( 1 ) ;
179+ expect ( TDD . grid . filterExpressions [ 0 ] . key ) . to . equal ( 'name' ) ;
180+ } ) ;
181+
182+ it ( 'Filter expressions late binding clears state with empty array' , async ( ) => {
183+ await TDD . updateColumns ( { field : 'id' , dataType : 'number' } ) ;
184+ await TDD . updateProperty ( 'filterExpressions' , [
185+ { key : 'id' , condition : 'greaterThanOrEqual' , searchTerm : 8 } ,
186+ ] ) ;
187+ expect ( TDD . grid . filterExpressions ) . lengthOf ( 1 ) ;
188+ expect ( TDD . grid . totalItems ) . to . equal ( 1 ) ;
189+
190+ await TDD . updateProperty ( 'filterExpressions' , [ ] ) ;
191+ expect ( TDD . grid . filterExpressions ) . lengthOf ( 0 ) ;
192+ expect ( TDD . grid . totalItems ) . to . equal ( data . length ) ;
193+ } ) ;
194+
149195 it ( 'Sort expressions (get)' , async ( ) => {
150196 await TDD . sort ( [
151197 { key : 'name' , direction : 'descending' } ,
0 commit comments