1717import 'app/../test/angular-testbed-init' ;
1818import { FormFieldErrors } from './errors.component' ;
1919import { assert } from 'chai' ;
20- import { TestBed , async , ComponentFixture , tick , fakeAsync } from '@angular/core/testing' ;
21- import { Component , NO_ERRORS_SCHEMA , Input , ViewChild , ElementRef } from '@angular/core' ;
20+ import { TestBed , ComponentFixture , fakeAsync } from '@angular/core/testing' ;
21+ import { Component , NO_ERRORS_SCHEMA , ViewChild , ElementRef } from '@angular/core' ;
2222
2323suite ( 'Angular form-field-errors component' , ( ) => {
2424 let fixture : ComponentFixture < HostComponent > ;
@@ -40,11 +40,13 @@ suite('Angular form-field-errors component', () => {
4040 `
4141 } )
4242 class HostComponent {
43- @ViewChild ( 'inline' , { read : ElementRef } )
44- inline : HTMLElement
45- @ViewChild ( 'icon' , { read : ElementRef } )
46- icon : HTMLElement
47- errorType = 'unique'
43+ @ViewChild ( 'inline' , { read : ElementRef , static : false } )
44+ inline : HTMLElement ;
45+
46+ @ViewChild ( 'icon' , { read : ElementRef , static : false } )
47+ icon : HTMLElement ;
48+
49+ errorType = 'unique' ;
4850 }
4951
5052 setup ( fakeAsync ( async ( ) => {
@@ -55,32 +57,39 @@ suite('Angular form-field-errors component', () => {
5557 ] ,
5658 schemas : [ NO_ERRORS_SCHEMA ]
5759 } ) . compileComponents ( ) ;
60+
5861 fixture = TestBed . createComponent ( HostComponent ) ;
5962 fixture . detectChanges ( ) ;
6063 } ) ) ;
64+
6165 test ( 'Error style' , ( ) => {
6266 assert . ok (
6367 fixture . debugElement . componentInstance . inline . nativeElement . querySelector ( '.inline' ) ,
6468 'It can show inline errors'
6569 ) ;
70+
6671 assert . ok (
6772 fixture . debugElement . componentInstance . icon . nativeElement . querySelector ( '.icon' ) ,
6873 'It can show icon errors'
6974 ) ;
7075 } ) ;
76+
7177 test ( 'Validation message' , ( ) => {
7278 assert . equal (
7379 'Value is required' ,
7480 fixture . debugElement . componentInstance . inline . nativeElement . textContent ,
7581 'It shows default message'
7682 ) ;
83+
7784 assert . equal (
7885 'Value should be unique' ,
7986 fixture . debugElement . componentInstance . icon . nativeElement . textContent ,
8087 'It shows custom message'
8188 ) ;
89+
8290 fixture . componentInstance . errorType = 'foo' ;
8391 fixture . detectChanges ( ) ;
92+
8493 assert . equal (
8594 'Value is invalid: foo' ,
8695 fixture . debugElement . componentInstance . icon . nativeElement . textContent ,
0 commit comments