From c4c5fa8f2e3fb701e1621641955cd837b9600a02 Mon Sep 17 00:00:00 2001 From: yigitfindikli Date: Sun, 14 Oct 2018 00:46:29 +0300 Subject: [PATCH] fixed #6679 - InputTextArea Unit Test Improvement resize function controls added. --- .../inputtextarea/inputtextarea.spec.ts | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/app/components/inputtextarea/inputtextarea.spec.ts b/src/app/components/inputtextarea/inputtextarea.spec.ts index 20629210838..18723cc8c87 100644 --- a/src/app/components/inputtextarea/inputtextarea.spec.ts +++ b/src/app/components/inputtextarea/inputtextarea.spec.ts @@ -5,7 +5,7 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { Component, DebugElement } from '@angular/core'; @Component({ - template: ` + template: ` ` }) class TestInputTextArea { @@ -55,4 +55,34 @@ describe('InputTextarea', () => { expect(onResizeSpy).toHaveBeenCalledTimes(4); }); + + it('should increment height', () => { + component.autoResize = true; + fixture.detectChanges(); + + const inputTextEl = fixture.debugElement.query(By.css('textarea')); + let cachedHeight = inputTextEl.nativeElement.style.height; + inputTextEl.nativeElement.value = "primeng"; + inputTextEl.nativeElement.dispatchEvent(new Event('input')); + fixture.detectChanges(); + + expect(inputTextEl.nativeElement.style.height).toBeGreaterThan(cachedHeight); + expect(inputTextEl.nativeElement.style.overflow).toEqual("hidden"); + }); + + it('should use resize with maxHeight', () => { + component.autoResize = true; + fixture.detectChanges(); + + const inputTextEl = fixture.debugElement.query(By.css('textarea')); + inputTextEl.nativeElement.style.maxHeight = 70+'px'; + fixture.detectChanges(); + + inputTextEl.nativeElement.value = "primeng rocks!"; + inputTextEl.nativeElement.dispatchEvent(new Event('input')); + fixture.detectChanges(); + + expect(inputTextEl.nativeElement.style.height).toEqual(inputTextEl.nativeElement.style.maxHeight); + expect(inputTextEl.nativeElement.style.overflowY).toEqual("scroll"); + }); });