11import { async , ComponentFixture , TestBed , inject , tick , fakeAsync } from '@angular/core/testing' ;
2- import { MatPaginatorModule } from './index' ;
3- import { MatPaginator } from './paginator' ;
42import { Component , ViewChild } from '@angular/core' ;
5- import { MatPaginatorIntl } from './paginator-intl' ;
63import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
74import { dispatchMouseEvent } from '@angular/cdk/testing' ;
85import { ThemePalette } from '@angular/material/core' ;
6+ import { MatSelect } from '@angular/material/select' ;
7+ import { By } from '@angular/platform-browser' ;
8+ import { MatPaginatorModule , MatPaginator , MatPaginatorIntl } from './index' ;
99
1010
1111describe ( 'MatPaginator' , ( ) => {
@@ -391,6 +391,29 @@ describe('MatPaginator', () => {
391391 . toBeNull ( 'Expected select to be removed.' ) ;
392392 } ) ;
393393
394+ it ( 'should be able to disable all the controls in the paginator via the binding' , ( ) => {
395+ const select : MatSelect = fixture . debugElement . query ( By . directive ( MatSelect ) ) . componentInstance ;
396+
397+ fixture . componentInstance . pageIndex = 1 ;
398+ fixture . componentInstance . showFirstLastButtons = true ;
399+ fixture . detectChanges ( ) ;
400+
401+ expect ( select . disabled ) . toBe ( false ) ;
402+ expect ( getPreviousButton ( fixture ) . hasAttribute ( 'disabled' ) ) . toBe ( false ) ;
403+ expect ( getNextButton ( fixture ) . hasAttribute ( 'disabled' ) ) . toBe ( false ) ;
404+ expect ( getFirstButton ( fixture ) . hasAttribute ( 'disabled' ) ) . toBe ( false ) ;
405+ expect ( getLastButton ( fixture ) . hasAttribute ( 'disabled' ) ) . toBe ( false ) ;
406+
407+ fixture . componentInstance . disabled = true ;
408+ fixture . detectChanges ( ) ;
409+
410+ expect ( select . disabled ) . toBe ( true ) ;
411+ expect ( getPreviousButton ( fixture ) . hasAttribute ( 'disabled' ) ) . toBe ( true ) ;
412+ expect ( getNextButton ( fixture ) . hasAttribute ( 'disabled' ) ) . toBe ( true ) ;
413+ expect ( getFirstButton ( fixture ) . hasAttribute ( 'disabled' ) ) . toBe ( true ) ;
414+ expect ( getLastButton ( fixture ) . hasAttribute ( 'disabled' ) ) . toBe ( true ) ;
415+ } ) ;
416+
394417} ) ;
395418
396419function getPreviousButton ( fixture : ComponentFixture < any > ) {
@@ -418,6 +441,7 @@ function getLastButton(fixture: ComponentFixture<any>) {
418441 [showFirstLastButtons]="showFirstLastButtons"
419442 [length]="length"
420443 [color]="color"
444+ [disabled]="disabled"
421445 (page)="pageEvent($event)">
422446 </mat-paginator>
423447 ` ,
@@ -429,6 +453,7 @@ class MatPaginatorApp {
429453 hidePageSize = false ;
430454 showFirstLastButtons = false ;
431455 length = 100 ;
456+ disabled : boolean ;
432457 pageEvent = jasmine . createSpy ( 'page event' ) ;
433458 color : ThemePalette ;
434459
0 commit comments