Override ActivatedRoute in Jasmine

Viewed 118

I'm trying to write some tests which in the ngInit() have some conditional logic which depends on ActivatedRoute.params to get a value.

My mock has provided an observable for my values, but when I debug, the specified ActivedRoute isn't set.

I have this working on a different test of a different component.

my injection is as:

beforeEach(async(() => {
TestBed.configureTestingModule({
  imports:[
    FaqsModule,SharedModule.forRoot(), RouterTestingModule
  ],
  declarations: [ ],
  providers:[
    { provide: AppService, useValue: new MockAppService() },
    { provide: DataService, useValue: mockDataService },
    { provide: NotificationService, useValue: mockNotificationService },
    { provide: FaqsService, useValue:mockFaqsService},
    { provide: ActivatedRoute, useValue: {queryParams: Observable.of({id:1}) }}
  ]
})
.compileComponents();

fixture = TestBed.createComponent(FaqEditPageComponent);
component = fixture.componentInstance;
}));

I have tried:

--Not including this provider

--Mocking this and providing as useClass

--Using override from the AngularDocs

0 Answers
Related