Skip to content

Commit

Permalink
GG-19447 Web Console: Updated Angular from 7 to 8. Fixes #135.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilya Borisov authored and akuznetsov-os committed Jun 19, 2019
1 parent 56ad1d8 commit 1d2119d
Show file tree
Hide file tree
Showing 6 changed files with 241 additions and 199 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class FormFieldError implements AfterViewInit {
@Input()
error: string;

@ViewChild('errorTemplate')
@ViewChild('errorTemplate', {static: false})
template: TemplateRef<any>;

static parameters = [[new Inject(ElementRef)], [new Inject(FormField)]];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import 'app/../test/angular-testbed-init';
import {FormFieldErrors} from './errors.component';
import {assert} from 'chai';
import {TestBed, async, ComponentFixture, tick, fakeAsync} from '@angular/core/testing';
import {Component, NO_ERRORS_SCHEMA, Input, ViewChild, ElementRef} from '@angular/core';
import {TestBed, ComponentFixture, fakeAsync} from '@angular/core/testing';
import {Component, NO_ERRORS_SCHEMA, ViewChild, ElementRef} from '@angular/core';

suite('Angular form-field-errors component', () => {
let fixture: ComponentFixture<HostComponent>;
Expand All @@ -40,11 +40,13 @@ suite('Angular form-field-errors component', () => {
`
})
class HostComponent {
@ViewChild('inline', {read: ElementRef})
inline: HTMLElement
@ViewChild('icon', {read: ElementRef})
icon: HTMLElement
errorType = 'unique'
@ViewChild('inline', {read: ElementRef, static: false})
inline: HTMLElement;

@ViewChild('icon', {read: ElementRef, static: false})
icon: HTMLElement;

errorType = 'unique';
}

setup(fakeAsync(async() => {
Expand All @@ -55,32 +57,39 @@ suite('Angular form-field-errors component', () => {
],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents();

fixture = TestBed.createComponent(HostComponent);
fixture.detectChanges();
}));

test('Error style', () => {
assert.ok(
fixture.debugElement.componentInstance.inline.nativeElement.querySelector('.inline'),
'It can show inline errors'
);

assert.ok(
fixture.debugElement.componentInstance.icon.nativeElement.querySelector('.icon'),
'It can show icon errors'
);
});

test('Validation message', () => {
assert.equal(
'Value is required',
fixture.debugElement.componentInstance.inline.nativeElement.textContent,
'It shows default message'
);

assert.equal(
'Value should be unique',
fixture.debugElement.componentInstance.icon.nativeElement.textContent,
'It shows custom message'
);

fixture.componentInstance.errorType = 'foo';
fixture.detectChanges();

assert.equal(
'Value is invalid: foo',
fixture.debugElement.componentInstance.icon.nativeElement.textContent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ export class FormField implements AfterViewInit {

extraMessages = {};

@ContentChild(FormControlName)
@ContentChild(FormControlName, {static: false})
control: FormControlName;

@ContentChild(FormFieldHint)
@ContentChild(FormFieldHint, {static: false})
hint: FormFieldHint;

@HostBinding('class.form-field__required')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ import {PopperContent} from 'ngx-popper';
`
})
export class FormFieldHint {
@ViewChild(PopperContent)
@ViewChild(PopperContent, {static: true})
popper: PopperContent
}

0 comments on commit 1d2119d

Please sign in to comment.