@@ -333,7 +333,7 @@ class ElementDataSource extends DataSource<PeriodicElement> {
333
333
}
334
334
335
335
// There's 1px of variance between different browsers in terms of positioning.
336
- const approximateMatcher = {
336
+ const approximateMatcher : jasmine . CustomMatcherFactories = {
337
337
isApproximately : ( ) => ( {
338
338
compare : ( actual : number , expected : number ) => {
339
339
const result = {
@@ -348,6 +348,14 @@ const approximateMatcher = {
348
348
} ) ,
349
349
} ;
350
350
351
+ interface NumberMatchers extends jasmine . Matchers < number > {
352
+ isApproximately ( expected : number ) : void ;
353
+ not : NumberMatchers ;
354
+ }
355
+ declare global {
356
+ function expect ( actual : number ) : NumberMatchers ;
357
+ }
358
+
351
359
const testCases = [
352
360
[ MatColumnResizeModule , MatResizeTest , 'opt-in table-based mat-table' ] ,
353
361
[ MatColumnResizeModule , MatResizeOnPushTest , 'inside OnPush component' ] ,
@@ -409,12 +417,8 @@ describe('Material Popover Edit', () => {
409
417
component . getOverlayThumbElement ( 2 ) . classList . contains ( 'mat-column-resize-overlay-thumb' ) ,
410
418
) . toBe ( true ) ;
411
419
412
- ( expect ( component . getOverlayThumbElement ( 0 ) . offsetHeight ) as any ) . isApproximately (
413
- headerRowHeight ,
414
- ) ;
415
- ( expect ( component . getOverlayThumbElement ( 2 ) . offsetHeight ) as any ) . isApproximately (
416
- headerRowHeight ,
417
- ) ;
420
+ expect ( component . getOverlayThumbElement ( 0 ) . offsetHeight ) . isApproximately ( headerRowHeight ) ;
421
+ expect ( component . getOverlayThumbElement ( 2 ) . offsetHeight ) . isApproximately ( headerRowHeight ) ;
418
422
419
423
component . beginColumnResizeWithMouse ( 0 ) ;
420
424
@@ -425,15 +429,11 @@ describe('Material Popover Edit', () => {
425
429
component . getOverlayThumbElement ( 2 ) . classList . contains ( 'mat-column-resize-overlay-thumb' ) ,
426
430
) . toBe ( true ) ;
427
431
428
- ( expect ( component . getOverlayThumbElement ( 0 ) . offsetHeight ) as any ) . isApproximately (
429
- tableHeight ,
430
- ) ;
431
- ( expect ( component . getOverlayThumbTopElement ( 0 ) . offsetHeight ) as any ) . isApproximately (
432
- headerRowHeight ,
433
- ) ;
434
- ( expect ( component . getOverlayThumbElement ( 2 ) . offsetHeight ) as any ) . isApproximately (
432
+ expect ( component . getOverlayThumbElement ( 0 ) . offsetHeight ) . isApproximately ( tableHeight ) ;
433
+ expect ( component . getOverlayThumbTopElement ( 0 ) . offsetHeight ) . isApproximately (
435
434
headerRowHeight ,
436
435
) ;
436
+ expect ( component . getOverlayThumbElement ( 2 ) . offsetHeight ) . isApproximately ( headerRowHeight ) ;
437
437
438
438
component . completeResizeWithMouseInProgress ( 0 ) ;
439
439
component . endHoverState ( ) ;
@@ -462,31 +462,31 @@ describe('Material Popover Edit', () => {
462
462
let columnPositionDelta = component . getColumnOriginPosition ( 1 ) - initialColumnPosition ;
463
463
// let nextColumnPositionDelta =
464
464
// component.getColumnOriginPosition(2) - initialNextColumnPosition;
465
- ( expect ( thumbPositionDelta ) as any ) . isApproximately ( columnPositionDelta ) ;
465
+ expect ( thumbPositionDelta ) . isApproximately ( columnPositionDelta ) ;
466
466
// TODO: This was commented out after switching from the legacy table to the current
467
467
// MDC-based table. This failed by being inaccurate by several pixels.
468
- // ( expect(nextColumnPositionDelta) as any ).isApproximately(columnPositionDelta);
468
+ // expect(nextColumnPositionDelta).isApproximately(columnPositionDelta);
469
469
470
470
// TODO: This was commented out after switching from the legacy table to the current
471
471
// MDC-based table. This failed by being inaccurate by several pixels.
472
- // ( expect(component.getTableWidth()) as any ).isApproximately(initialTableWidth + 5);
473
- ( expect ( component . getColumnWidth ( 1 ) ) as any ) . isApproximately ( initialColumnWidth + 5 ) ;
472
+ // expect(component.getTableWidth()).isApproximately(initialTableWidth + 5);
473
+ expect ( component . getColumnWidth ( 1 ) ) . isApproximately ( initialColumnWidth + 5 ) ;
474
474
475
475
component . updateResizeWithMouseInProgress ( 1 ) ;
476
476
fixture . detectChanges ( ) ;
477
477
flush ( ) ;
478
478
479
479
thumbPositionDelta = component . getOverlayThumbPosition ( 1 ) - initialThumbPosition ;
480
480
columnPositionDelta = component . getColumnOriginPosition ( 1 ) - initialColumnPosition ;
481
- ( expect ( thumbPositionDelta ) as any ) . isApproximately ( columnPositionDelta ) ;
481
+ expect ( thumbPositionDelta ) . isApproximately ( columnPositionDelta ) ;
482
482
483
- ( expect ( component . getTableWidth ( ) ) as any ) . isApproximately ( initialTableWidth + 1 ) ;
484
- ( expect ( component . getColumnWidth ( 1 ) ) as any ) . isApproximately ( initialColumnWidth + 1 ) ;
483
+ expect ( component . getTableWidth ( ) ) . isApproximately ( initialTableWidth + 1 ) ;
484
+ expect ( component . getColumnWidth ( 1 ) ) . isApproximately ( initialColumnWidth + 1 ) ;
485
485
486
486
component . completeResizeWithMouseInProgress ( 1 ) ;
487
487
flush ( ) ;
488
488
489
- ( expect ( component . getColumnWidth ( 1 ) ) as any ) . isApproximately ( initialColumnWidth + 1 ) ;
489
+ expect ( component . getColumnWidth ( 1 ) ) . isApproximately ( initialColumnWidth + 1 ) ;
490
490
491
491
component . endHoverState ( ) ;
492
492
fixture . detectChanges ( ) ;
@@ -508,23 +508,23 @@ describe('Material Popover Edit', () => {
508
508
flush ( ) ;
509
509
510
510
let thumbPositionDelta = component . getOverlayThumbPosition ( 1 ) - initialThumbPosition ;
511
- ( expect ( thumbPositionDelta ) as any ) . isApproximately ( 5 ) ;
512
- ( expect ( component . getColumnWidth ( 1 ) ) as any ) . toBe ( initialColumnWidth ) ;
511
+ expect ( thumbPositionDelta ) . isApproximately ( 5 ) ;
512
+ expect ( component . getColumnWidth ( 1 ) ) . toBe ( initialColumnWidth ) ;
513
513
514
514
component . updateResizeWithMouseInProgress ( 1 ) ;
515
515
fixture . detectChanges ( ) ;
516
516
flush ( ) ;
517
517
518
518
thumbPositionDelta = component . getOverlayThumbPosition ( 1 ) - initialThumbPosition ;
519
519
520
- ( expect ( component . getTableWidth ( ) ) as any ) . toBe ( initialTableWidth ) ;
521
- ( expect ( component . getColumnWidth ( 1 ) ) as any ) . toBe ( initialColumnWidth ) ;
520
+ expect ( component . getTableWidth ( ) ) . toBe ( initialTableWidth ) ;
521
+ expect ( component . getColumnWidth ( 1 ) ) . toBe ( initialColumnWidth ) ;
522
522
523
523
component . completeResizeWithMouseInProgress ( 1 ) ;
524
524
flush ( ) ;
525
525
526
- ( expect ( component . getTableWidth ( ) ) as any ) . isApproximately ( initialTableWidth + 1 ) ;
527
- ( expect ( component . getColumnWidth ( 1 ) ) as any ) . isApproximately ( initialColumnWidth + 1 ) ;
526
+ expect ( component . getTableWidth ( ) ) . isApproximately ( initialTableWidth + 1 ) ;
527
+ expect ( component . getColumnWidth ( 1 ) ) . isApproximately ( initialColumnWidth + 1 ) ;
528
528
529
529
component . endHoverState ( ) ;
530
530
fixture . detectChanges ( ) ;
@@ -562,18 +562,18 @@ describe('Material Popover Edit', () => {
562
562
563
563
let thumbPositionDelta = component . getOverlayThumbPosition ( 1 ) - initialThumbPosition ;
564
564
let columnPositionDelta = component . getColumnOriginPosition ( 1 ) - initialColumnPosition ;
565
- ( expect ( thumbPositionDelta ) as any ) . isApproximately ( columnPositionDelta ) ;
565
+ expect ( thumbPositionDelta ) . isApproximately ( columnPositionDelta ) ;
566
566
567
- ( expect ( component . getColumnWidth ( 1 ) ) as any ) . isApproximately ( initialColumnWidth + 5 ) ;
567
+ expect ( component . getColumnWidth ( 1 ) ) . isApproximately ( initialColumnWidth + 5 ) ;
568
568
// TODO: This was commented out after switching from the legacy table to the current
569
569
// MDC-based table. This failed by being inaccurate by several pixels.
570
- // ( expect(component.getTableWidth()) as any ).isApproximately(initialTableWidth + 5);
570
+ // expect(component.getTableWidth()).isApproximately(initialTableWidth + 5);
571
571
572
572
dispatchKeyboardEvent ( document , 'keyup' , ESCAPE ) ;
573
573
flush ( ) ;
574
574
575
- ( expect ( component . getColumnWidth ( 1 ) ) as any ) . isApproximately ( initialColumnWidth ) ;
576
- ( expect ( component . getTableWidth ( ) ) as any ) . isApproximately ( initialTableWidth ) ;
575
+ expect ( component . getColumnWidth ( 1 ) ) . isApproximately ( initialColumnWidth ) ;
576
+ expect ( component . getTableWidth ( ) ) . isApproximately ( initialTableWidth ) ;
577
577
578
578
component . endHoverState ( ) ;
579
579
fixture . detectChanges ( ) ;
@@ -582,7 +582,7 @@ describe('Material Popover Edit', () => {
582
582
it ( 'notifies subscribers of a completed resize via ColumnResizeNotifier' , fakeAsync ( ( ) => {
583
583
const initialColumnWidth = component . getColumnWidth ( 1 ) ;
584
584
585
- let resize : ColumnSize | null = null ;
585
+ let resize : ColumnSize | null = null as ColumnSize | null ;
586
586
component . columnResize . columnResizeNotifier . resizeCompleted . subscribe ( size => {
587
587
resize = size ;
588
588
} ) ;
@@ -596,7 +596,7 @@ describe('Material Popover Edit', () => {
596
596
fixture . detectChanges ( ) ;
597
597
flush ( ) ;
598
598
599
- expect ( resize ) . toEqual ( { columnId : 'name' , size : initialColumnWidth + 5 } as any ) ;
599
+ expect ( resize ) . toEqual ( { columnId : 'name' , size : initialColumnWidth + 5 } ) ;
600
600
601
601
component . endHoverState ( ) ;
602
602
fixture . detectChanges ( ) ;
@@ -626,12 +626,12 @@ describe('Material Popover Edit', () => {
626
626
627
627
it ( 'performs a column resize triggered via ColumnResizeNotifier' , fakeAsync ( ( ) => {
628
628
// Pre-verify that we are not updating the size to the initial size.
629
- ( expect ( component . getColumnWidth ( 1 ) ) as any ) . not . isApproximately ( 173 ) ;
629
+ expect ( component . getColumnWidth ( 1 ) ) . not . isApproximately ( 173 ) ;
630
630
631
631
component . columnResize . columnResizeNotifier . resize ( 'name' , 173 ) ;
632
632
flush ( ) ;
633
633
634
- ( expect ( component . getColumnWidth ( 1 ) ) as any ) . isApproximately ( 173 ) ;
634
+ expect ( component . getColumnWidth ( 1 ) ) . isApproximately ( 173 ) ;
635
635
} ) ) ;
636
636
} ) ;
637
637
}
@@ -660,13 +660,13 @@ describe('Material Popover Edit', () => {
660
660
} ) ) ;
661
661
662
662
it ( 'applies the persisted size' , fakeAsync ( ( ) => {
663
- ( expect ( component . getColumnWidth ( 1 ) ) . not as any ) . isApproximately ( 300 ) ;
663
+ expect ( component . getColumnWidth ( 1 ) ) . not . isApproximately ( 300 ) ;
664
664
665
665
columnSizeStore . emitSize ( 'theTable' , 'name' , 300 ) ;
666
666
667
667
flush ( ) ;
668
668
669
- ( expect ( component . getColumnWidth ( 1 ) ) as any ) . isApproximately ( 300 ) ;
669
+ expect ( component . getColumnWidth ( 1 ) ) . isApproximately ( 300 ) ;
670
670
} ) ) ;
671
671
672
672
it ( 'persists the user-triggered size update' , fakeAsync ( ( ) => {
@@ -689,7 +689,7 @@ describe('Material Popover Edit', () => {
689
689
const { tableId, columnId, sizePx} = columnSizeStore . setSizeCalls [ 0 ] ;
690
690
expect ( tableId ) . toBe ( 'theTable' ) ;
691
691
expect ( columnId ) . toBe ( 'name' ) ;
692
- ( expect ( sizePx ) as any ) . isApproximately ( initialColumnWidth + 5 ) ;
692
+ expect ( sizePx ) . isApproximately ( initialColumnWidth + 5 ) ;
693
693
} ) ) ;
694
694
695
695
it ( 'persists the user-triggered size update (live updates off)' , fakeAsync ( ( ) => {
@@ -714,7 +714,7 @@ describe('Material Popover Edit', () => {
714
714
const { tableId, columnId, sizePx} = columnSizeStore . setSizeCalls [ 0 ] ;
715
715
expect ( tableId ) . toBe ( 'theTable' ) ;
716
716
expect ( columnId ) . toBe ( 'name' ) ;
717
- ( expect ( sizePx ) as any ) . isApproximately ( initialColumnWidth + 5 ) ;
717
+ expect ( sizePx ) . isApproximately ( initialColumnWidth + 5 ) ;
718
718
} ) ) ;
719
719
} ) ;
720
720
} ) ;
0 commit comments