Skip to content

Instantly share code, notes, and snippets.

@andersonleite
Created August 22, 2018 19:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andersonleite/625efd426b6cd09255bdea8accd24bcc to your computer and use it in GitHub Desktop.
Save andersonleite/625efd426b6cd09255bdea8accd24bcc to your computer and use it in GitHub Desktop.
Testing components
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AnalyticsSelectorComponent } from './analytics-selector.component';
import { MatFormFieldModule, MatInputModule } from '@angular/material';
import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
describe('AnalyticsSelectorComponent', () => {
let component: AnalyticsSelectorComponent;
let fixture: ComponentFixture<AnalyticsSelectorComponent>;
const formBuilder: FormBuilder = new FormBuilder();
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [AnalyticsSelectorComponent],
imports: [MatFormFieldModule, ReactiveFormsModule, MatInputModule, BrowserAnimationsModule],
providers: [ { provide: FormBuilder, useValue: formBuilder } ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AnalyticsSelectorComponent);
component = fixture.componentInstance;
component.parent = formBuilder.group({
google_analytics: ['google_analytics', Validators.required]
});
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment