@@ -5,6 +5,8 @@ import {createKeyboardEvent} from '@angular/cdk/testing';
55import { Component , DebugElement } from '@angular/core' ;
66import { async , ComponentFixture , TestBed } from '@angular/core/testing' ;
77import { By } from '@angular/platform-browser' ;
8+ import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
9+ import { MatFormFieldModule } from '@angular/material/form-field' ;
810import { MatChipInput , MatChipInputEvent } from './chip-input' ;
911import { MatChipsModule } from './index' ;
1012import { MAT_CHIPS_DEFAULT_OPTIONS , MatChipsDefaultOptions } from './chip-default-options' ;
@@ -20,7 +22,7 @@ describe('MatChipInput', () => {
2022
2123 beforeEach ( async ( ( ) => {
2224 TestBed . configureTestingModule ( {
23- imports : [ MatChipsModule , PlatformModule ] ,
25+ imports : [ PlatformModule , MatChipsModule , MatFormFieldModule , NoopAnimationsModule ] ,
2426 declarations : [ TestChipInput ] ,
2527 providers : [ {
2628 provide : Directionality , useFactory : ( ) => {
@@ -64,6 +66,22 @@ describe('MatChipInput', () => {
6466
6567 expect ( inputNativeElement . getAttribute ( 'placeholder' ) ) . toBe ( 'bound placeholder' ) ;
6668 } ) ;
69+
70+ it ( 'should propagate the dynamic `placeholder` value to the form field' , ( ) => {
71+ fixture . componentInstance . placeholder = 'add a chip' ;
72+ fixture . detectChanges ( ) ;
73+
74+ const label : HTMLElement = fixture . nativeElement . querySelector ( '.mat-form-field-label' ) ;
75+
76+ expect ( label ) . toBeTruthy ( ) ;
77+ expect ( label . textContent ) . toContain ( 'add a chip' ) ;
78+
79+ fixture . componentInstance . placeholder = 'or don\'t' ;
80+ fixture . detectChanges ( ) ;
81+
82+ expect ( label . textContent ) . toContain ( 'or don\'t' ) ;
83+ } ) ;
84+
6785 } ) ;
6886
6987 describe ( '[addOnBlur]' , ( ) => {
@@ -117,7 +135,7 @@ describe('MatChipInput', () => {
117135 TestBed
118136 . resetTestingModule ( )
119137 . configureTestingModule ( {
120- imports : [ MatChipsModule , PlatformModule ] ,
138+ imports : [ MatChipsModule , MatFormFieldModule , PlatformModule , NoopAnimationsModule ] ,
121139 declarations : [ TestChipInput ] ,
122140 providers : [ {
123141 provide : MAT_CHIPS_DEFAULT_OPTIONS ,
@@ -146,12 +164,14 @@ describe('MatChipInput', () => {
146164
147165@Component ( {
148166 template : `
149- <mat-chip-list #chipList>
150- </mat-chip-list>
151- <input matInput [matChipInputFor]="chipList"
152- [matChipInputAddOnBlur]="addOnBlur"
153- (matChipInputTokenEnd)="add($event)"
154- [placeholder]="placeholder" />
167+ <mat-form-field>
168+ <mat-chip-list #chipList>
169+ </mat-chip-list>
170+ <input matInput [matChipInputFor]="chipList"
171+ [matChipInputAddOnBlur]="addOnBlur"
172+ (matChipInputTokenEnd)="add($event)"
173+ [placeholder]="placeholder" />
174+ </mat-form-field>
155175 `
156176} )
157177class TestChipInput {
0 commit comments