@@ -180,6 +180,15 @@ describe('MatSort', () => {
180180 expectedStates . set ( 'defaultB' , { viewState : 'asc-to-active' , arrowDirection : 'active-asc' } ) ;
181181 component . expectViewAndDirectionStates ( expectedStates ) ;
182182 } ) ;
183+
184+ it ( 'should be correct when sort has been disabled' , ( ) => {
185+ // Mousing over the first sort should set the view state to hint
186+ component . disabledColumnSort = true ;
187+ fixture . detectChanges ( ) ;
188+
189+ component . dispatchMouseEvent ( 'defaultA' , 'mouseenter' ) ;
190+ component . expectViewAndDirectionStates ( expectedStates ) ;
191+ } ) ;
183192 } ) ;
184193
185194 it ( 'should be able to cycle from asc -> desc from either start point' , ( ) => {
@@ -204,38 +213,38 @@ describe('MatSort', () => {
204213 } ) ;
205214
206215 it ( 'should allow for the cycling the sort direction to be disabled per column' , ( ) => {
207- const button = fixture . nativeElement . querySelector ( '#defaultSortHeaderA button' ) ;
216+ const button = fixture . nativeElement . querySelector ( '#defaultA button' ) ;
208217
209- component . sort ( 'defaultSortHeaderA ' ) ;
218+ component . sort ( 'defaultA ' ) ;
210219 expect ( component . matSort . direction ) . toBe ( 'asc' ) ;
211220 expect ( button . getAttribute ( 'disabled' ) ) . toBeFalsy ( ) ;
212221
213222 component . disabledColumnSort = true ;
214223 fixture . detectChanges ( ) ;
215224
216- component . sort ( 'defaultSortHeaderA ' ) ;
225+ component . sort ( 'defaultA ' ) ;
217226 expect ( component . matSort . direction ) . toBe ( 'asc' ) ;
218227 expect ( button . getAttribute ( 'disabled' ) ) . toBe ( 'true' ) ;
219228 } ) ;
220229
221230 it ( 'should allow for the cycling the sort direction to be disabled for all columns' , ( ) => {
222- const button = fixture . nativeElement . querySelector ( '#defaultSortHeaderA button' ) ;
231+ const button = fixture . nativeElement . querySelector ( '#defaultA button' ) ;
223232
224- component . sort ( 'defaultSortHeaderA ' ) ;
225- expect ( component . matSort . active ) . toBe ( 'defaultSortHeaderA ' ) ;
233+ component . sort ( 'defaultA ' ) ;
234+ expect ( component . matSort . active ) . toBe ( 'defaultA ' ) ;
226235 expect ( component . matSort . direction ) . toBe ( 'asc' ) ;
227236 expect ( button . getAttribute ( 'disabled' ) ) . toBeFalsy ( ) ;
228237
229238 component . disableAllSort = true ;
230239 fixture . detectChanges ( ) ;
231240
232- component . sort ( 'defaultSortHeaderA ' ) ;
233- expect ( component . matSort . active ) . toBe ( 'defaultSortHeaderA ' ) ;
241+ component . sort ( 'defaultA ' ) ;
242+ expect ( component . matSort . active ) . toBe ( 'defaultA ' ) ;
234243 expect ( component . matSort . direction ) . toBe ( 'asc' ) ;
235244 expect ( button . getAttribute ( 'disabled' ) ) . toBe ( 'true' ) ;
236245
237- component . sort ( 'defaultSortHeaderB ' ) ;
238- expect ( component . matSort . active ) . toBe ( 'defaultSortHeaderA ' ) ;
246+ component . sort ( 'defaultB ' ) ;
247+ expect ( component . matSort . active ) . toBe ( 'defaultA ' ) ;
239248 expect ( component . matSort . direction ) . toBe ( 'asc' ) ;
240249 expect ( button . getAttribute ( 'disabled' ) ) . toBe ( 'true' ) ;
241250 } ) ;
@@ -359,7 +368,7 @@ describe('MatSort', () => {
359368 */
360369function testSingleColumnSortDirectionSequence ( fixture : ComponentFixture < SimpleMatSortApp > ,
361370 expectedSequence : SortDirection [ ] ,
362- id : string = 'defaultA' ) {
371+ id : SimpleMatSortAppColumnIds = 'defaultA' ) {
363372 // Detect any changes that were made in preparation for this sort sequence
364373 fixture . detectChanges ( ) ;
365374
@@ -387,6 +396,9 @@ function testSingleColumnSortDirectionSequence(fixture: ComponentFixture<SimpleM
387396 expect ( component . matSort . direction ) . toBe ( expectedSequence [ 0 ] ) ;
388397}
389398
399+ /** Column IDs of the SimpleMatSortApp for typing of function params in the component (e.g. sort) */
400+ type SimpleMatSortAppColumnIds = 'defaultA' | 'defaultB' | 'overrideStart' | 'overrideDisableClear' ;
401+
390402@Component ( {
391403 template : `
392404 <div matSort
@@ -397,7 +409,9 @@ function testSingleColumnSortDirectionSequence(fixture: ComponentFixture<SimpleM
397409 [matSortDisableClear]="disableClear"
398410 (matSortChange)="latestSortEvent = $event">
399411 <div id="defaultA"
400- #defaultA mat-sort-header="defaultA"[disabled]="disabledColumnSort">
412+ #defaultA
413+ mat-sort-header="defaultA"
414+ [disabled]="disabledColumnSort">
401415 A
402416 </div>
403417 <div id="defaultB"
@@ -408,12 +422,14 @@ function testSingleColumnSortDirectionSequence(fixture: ComponentFixture<SimpleM
408422 <div id="overrideStart"
409423 #overrideStart
410424 mat-sort-header="overrideStart" start="desc">
411- D </div>
425+ D
426+ </div>
412427 <div id="overrideDisableClear"
413428 #overrideDisableClear
414429 mat-sort-header="overrideDisableClear"
415430 disableClear>
416- E </div>
431+ E
432+ </div>
417433 </div>
418434 `
419435} )
@@ -435,11 +451,11 @@ class SimpleMatSortApp {
435451
436452 constructor ( public elementRef : ElementRef ) { }
437453
438- sort ( id : string ) {
454+ sort ( id : SimpleMatSortAppColumnIds ) {
439455 this . dispatchMouseEvent ( id , 'click' ) ;
440456 }
441457
442- dispatchMouseEvent ( id : string , event : string ) {
458+ dispatchMouseEvent ( id : SimpleMatSortAppColumnIds , event : string ) {
443459 const sortElement = this . elementRef . nativeElement . querySelector ( `#${ id } ` ) ;
444460 dispatchMouseEvent ( sortElement , event ) ;
445461 }
0 commit comments