@@ -1561,6 +1561,44 @@ describe('MatStepper', () => {
15611561 expect ( fixture . componentInstance . index ) . toBe ( 0 ) ;
15621562 } ) ;
15631563 } ) ;
1564+
1565+ describe ( 'stepper with header prefix' , ( ) => {
1566+ it ( 'should render the horizontal prefix content before the header' , ( ) => {
1567+ const fixture = createComponent ( HorizontalStepperWithHeaderPrefix ) ;
1568+ fixture . detectChanges ( ) ;
1569+
1570+ const stepperHeaderWrapper = fixture . nativeElement . querySelector (
1571+ '.mat-horizontal-stepper-header-wrapper' ,
1572+ ) ;
1573+
1574+ expect ( stepperHeaderWrapper . children . length ) . toBe ( 2 ) ;
1575+
1576+ const stepperHeaderWrapperChildrenTags = Array . from (
1577+ stepperHeaderWrapper . children as HTMLElement [ ] ,
1578+ ) . map ( ( child : HTMLElement ) => child . tagName ) ;
1579+ const stepperHeaderPrefix = stepperHeaderWrapper . children [ 0 ] ;
1580+
1581+ expect ( stepperHeaderWrapperChildrenTags ) . toEqual ( [ 'H2' , 'DIV' ] ) ;
1582+ expect ( stepperHeaderPrefix . textContent ) . toContain ( 'This is a header prefix' ) ;
1583+ } ) ;
1584+
1585+ it ( 'should render the vertical prefix content before the first step' , ( ) => {
1586+ const fixture = createComponent ( VerticalStepperWithHeaderPrefix ) ;
1587+ fixture . detectChanges ( ) ;
1588+
1589+ const stepperWrapper = fixture . nativeElement . querySelector ( '.mat-vertical-stepper-wrapper' ) ;
1590+
1591+ expect ( stepperWrapper . children . length ) . toBe ( 4 ) ;
1592+
1593+ const stepperHeaderWrapperChildrenTags = Array . from (
1594+ stepperWrapper . children as HTMLElement [ ] ,
1595+ ) . map ( ( child : HTMLElement ) => child . tagName ) ;
1596+ const stepperHeaderPrefix = stepperWrapper . children [ 0 ] ;
1597+
1598+ expect ( stepperHeaderWrapperChildrenTags ) . toEqual ( [ 'H2' , 'DIV' , 'DIV' , 'DIV' ] ) ;
1599+ expect ( stepperHeaderPrefix . textContent ) . toContain ( 'This is a header prefix' ) ;
1600+ } ) ;
1601+ } ) ;
15641602} ) ;
15651603
15661604/** Asserts that keyboard interaction works correctly. */
@@ -2258,3 +2296,39 @@ class HorizontalStepperWithDelayedStep {
22582296class StepperWithTwoWayBindingOnSelectedIndex {
22592297 index : number = 0 ;
22602298}
2299+
2300+ @Component ( {
2301+ template : `
2302+ <mat-stepper [headerPrefix]="stepHeaderPrefix" linear>
2303+ <mat-step label="One"></mat-step>
2304+ <mat-step label="Two"></mat-step>
2305+ <mat-step label="Three"></mat-step>
2306+ </mat-stepper>
2307+
2308+ <ng-template #stepHeaderPrefix>
2309+ <h2>This is a header prefix</h2>
2310+ </ng-template>
2311+ ` ,
2312+ imports : [ MatStepperModule ] ,
2313+ } )
2314+ class HorizontalStepperWithHeaderPrefix {
2315+ @ViewChild ( MatStepper ) stepper : MatStepper ;
2316+ }
2317+
2318+ @Component ( {
2319+ template : `
2320+ <mat-stepper [headerPrefix]="stepHeaderPrefix" orientation="vertical" linear>
2321+ <mat-step label="One"></mat-step>
2322+ <mat-step label="Two"></mat-step>
2323+ <mat-step label="Three"></mat-step>
2324+ </mat-stepper>
2325+
2326+ <ng-template #stepHeaderPrefix>
2327+ <h2>This is a header prefix</h2>
2328+ </ng-template>
2329+ ` ,
2330+ imports : [ MatStepperModule ] ,
2331+ } )
2332+ class VerticalStepperWithHeaderPrefix {
2333+ @ViewChild ( MatStepper ) stepper : MatStepper ;
2334+ }
0 commit comments