siema. Mam problem z wstrzyknięciem do testów w angularze ActiveRoute z parametrami.
describe('ReportEditComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
ReportEditComponent,
],
imports: [
FormsModule, ReactiveFormsModule,
AppMaterialModule, RouterTestingModule
],
providers: [
{
provide: ActivatedRoute, useValue: {
paramMap: Observable.of(convertToParamMap({date: 'luty 2016' }))
}
}
]
})
.compileComponents();
}));
it('should get correct params', () => {
const fixture = TestBed.createComponent(ReportEditComponent);
const component = fixture.componentInstance;
component.initCurrentDate();
});
});
a w componencie metoda initCurrentDate
initCurrentDate() {
const param = this.route.snapshot.paramMap.get('date');
const current = param.split(/\s/);
this.currentMonth = current[0];
this.currentYear = +current[1];
}
jak odpalam test ukazuje mi się cos takiego this.route.snapshot is undefined ?
jak rozwiązać ten problem