@@ -267,6 +267,35 @@ describe('MatTable', () => {
267
267
] ) ;
268
268
} ) ;
269
269
270
+ it ( 'should sort zero correctly' , ( ) => {
271
+ // Activate column A sort
272
+ dataSource . data [ 0 ] . a = 1 ;
273
+ dataSource . data [ 1 ] . a = 0 ;
274
+ dataSource . data [ 2 ] . a = - 1 ;
275
+
276
+ // Expect that zero comes after the negative numbers and before the positive ones.
277
+ component . sort . sort ( component . sortHeader ) ;
278
+ fixture . detectChanges ( ) ;
279
+ expectTableToMatchContent ( tableElement , [
280
+ [ 'Column A\xa0Sorted by a ascending' , 'Column B' , 'Column C' ] ,
281
+ [ '-1' , 'b_3' , 'c_3' ] ,
282
+ [ '0' , 'b_2' , 'c_2' ] ,
283
+ [ '1' , 'b_1' , 'c_1' ] ,
284
+ ] ) ;
285
+
286
+
287
+ // Expect that zero comes after the negative numbers and before
288
+ // the positive ones when switching the sorting direction.
289
+ component . sort . sort ( component . sortHeader ) ;
290
+ fixture . detectChanges ( ) ;
291
+ expectTableToMatchContent ( tableElement , [
292
+ [ 'Column A\xa0Sorted by a descending' , 'Column B' , 'Column C' ] ,
293
+ [ '1' , 'b_1' , 'c_1' ] ,
294
+ [ '0' , 'b_2' , 'c_2' ] ,
295
+ [ '-1' , 'b_3' , 'c_3' ] ,
296
+ ] ) ;
297
+ } ) ;
298
+
270
299
it ( 'should be able to page the table contents' , fakeAsync ( ( ) => {
271
300
// Add 100 rows, should only display first 5 since page length is 5
272
301
for ( let i = 0 ; i < 100 ; i ++ ) {
@@ -299,9 +328,9 @@ describe('MatTable', () => {
299
328
} ) ;
300
329
301
330
interface TestData {
302
- a : string | undefined ;
303
- b : string | undefined ;
304
- c : string | undefined ;
331
+ a : string | number | undefined ;
332
+ b : string | number | undefined ;
333
+ c : string | number | undefined ;
305
334
}
306
335
307
336
class FakeDataSource extends DataSource < TestData > {
0 commit comments