@@ -50,7 +50,7 @@ describe('CdkTextareaAutosize', () => {
5050 it ( 'should resize the textarea based on its content' , ( ) => {
5151 let previousHeight = textarea . clientHeight ;
5252
53- textarea . value = `
53+ fixture . componentInstance . content = `
5454 Once upon a midnight dreary, while I pondered, weak and weary,
5555 Over many a quaint and curious volume of forgotten lore—
5656 While I nodded, nearly napping, suddenly there came a tapping,
@@ -68,7 +68,7 @@ describe('CdkTextareaAutosize', () => {
6868 . toBe ( textarea . scrollHeight , 'Expected textarea height to match its scrollHeight' ) ;
6969
7070 previousHeight = textarea . clientHeight ;
71- textarea . value += `
71+ fixture . componentInstance . content += `
7272 Ah, distinctly I remember it was in the bleak December;
7373 And each separate dying ember wrought its ghost upon the floor.
7474 Eagerly I wished the morrow;—vainly I had sought to borrow
@@ -85,38 +85,6 @@ describe('CdkTextareaAutosize', () => {
8585 . toBe ( textarea . scrollHeight , 'Expected textarea height to match its scrollHeight' ) ;
8686 } ) ;
8787
88- it ( 'should keep the placeholder size if the value is shorter than the placeholder' , ( ) => {
89- fixture = TestBed . createComponent ( AutosizeTextAreaWithContent ) ;
90-
91- textarea = fixture . nativeElement . querySelector ( 'textarea' ) ;
92- autosize = fixture . debugElement . query ( By . css ( 'textarea' ) ) !
93- . injector . get < CdkTextareaAutosize > ( CdkTextareaAutosize ) ;
94-
95- fixture . componentInstance . placeholder = `
96- Once upon a midnight dreary, while I pondered, weak and weary,
97- Over many a quaint and curious volume of forgotten lore—
98- While I nodded, nearly napping, suddenly there came a tapping,
99- As of some one gently rapping, rapping at my chamber door.
100- “’Tis some visitor,” I muttered, “tapping at my chamber door—
101- Only this and nothing more.”` ;
102-
103- fixture . detectChanges ( ) ;
104-
105- expect ( textarea . clientHeight )
106- . toBe ( textarea . scrollHeight , 'Expected textarea height to match its scrollHeight' ) ;
107-
108- let previousHeight = textarea . clientHeight ;
109-
110- textarea . value = 'a' ;
111-
112- // Manually call resizeToFitContent instead of faking an `input` event.
113- fixture . detectChanges ( ) ;
114- autosize . resizeToFitContent ( ) ;
115-
116- expect ( textarea . clientHeight )
117- . toBe ( previousHeight , 'Expected textarea height not to have changed' ) ;
118- } ) ;
119-
12088 it ( 'should set a min-height based on minRows' , ( ) => {
12189 expect ( textarea . style . minHeight ) . toBeFalsy ( ) ;
12290
@@ -193,7 +161,7 @@ describe('CdkTextareaAutosize', () => {
193161 } ) ;
194162
195163 it ( 'should calculate the proper height based on the specified amount of max rows' , ( ) => {
196- textarea . value = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ] . join ( '\n' ) ;
164+ fixture . componentInstance . content = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ] . join ( '\n' ) ;
197165 fixture . detectChanges ( ) ;
198166 autosize . resizeToFitContent ( ) ;
199167
@@ -228,27 +196,6 @@ describe('CdkTextareaAutosize', () => {
228196 . toBe ( textarea . scrollHeight , 'Expected textarea height to match its scrollHeight' ) ;
229197 } ) ;
230198
231- it ( 'should properly resize to placeholder on init' , ( ) => {
232- // Manually create the test component in this test, because in this test the first change
233- // detection should be triggered after a multiline placeholder is set.
234- fixture = TestBed . createComponent ( AutosizeTextAreaWithContent ) ;
235- textarea = fixture . nativeElement . querySelector ( 'textarea' ) ;
236- autosize = fixture . debugElement . query ( By . css ( 'textarea' ) ) !
237- . injector . get < CdkTextareaAutosize > ( CdkTextareaAutosize ) ;
238-
239- fixture . componentInstance . placeholder = `
240- Line
241- Line
242- Line
243- Line
244- Line` ;
245-
246- fixture . detectChanges ( ) ;
247-
248- expect ( textarea . clientHeight )
249- . toBe ( textarea . scrollHeight , 'Expected textarea height to match its scrollHeight' ) ;
250- } ) ;
251-
252199 it ( 'should resize when an associated form control value changes' , fakeAsync ( ( ) => {
253200 const fixtureWithForms = TestBed . createComponent ( AutosizeTextareaWithNgModel ) ;
254201 textarea = fixtureWithForms . nativeElement . querySelector ( 'textarea' ) ;
@@ -351,15 +298,14 @@ const textareaStyleReset = `
351298@Component ( {
352299 template : `
353300 <textarea cdkTextareaAutosize [cdkAutosizeMinRows]="minRows" [cdkAutosizeMaxRows]="maxRows"
354- #autosize="cdkTextareaAutosize" [placeholder]="placeholder" >{{content}}</textarea>` ,
301+ #autosize="cdkTextareaAutosize">{{content}}</textarea>` ,
355302 styles : [ textareaStyleReset ] ,
356303} )
357304class AutosizeTextAreaWithContent {
358305 @ViewChild ( 'autosize' ) autosize : CdkTextareaAutosize ;
359306 minRows : number | null = null ;
360307 maxRows : number | null = null ;
361308 content : string = '' ;
362- placeholder : string = '' ;
363309}
364310
365311@Component ( {
0 commit comments