I am working with two Mock services:
@Injectable()
class UserRegistrationServiceMock {
registerBasicDetails(details: UserRegistrationDetails) {
let response: UserRegistrationResponse = new UserRegistrationResponse();
response.success = false;
response.userMessage = 'Test Message';
return Observable.of(response);
}
registerAdvancedDetails() {
}
}
@Injectable()
class UserRegistrationServiceSuccessMock {
registerBasicDetails(details: UserRegistrationDetails) {
let response: UserRegistrationResponse = new UserRegistrationResponse();
response.success = true;
response.userMessage = 'Test Message';
return Observable.of(response);
}
registerAdvancedDetails() {
}
}
When setting up my Jasmine test, I include the service definitions in the "beforeEachProviders" and "beforeEach" methods:
beforeEachProviders(() => [
provide(UserRegistrationService, { useClass: UserRegistrationServiceMock })
]);
beforeEach(inject([UserRegistrationService], (_userRegistration))
Then, in my test, I use the user registration service to initialize the component:
it('should create an instance', () => {
let component: BasicRegistrationComponent =
new BasicRegistrationComponent(null, formBuilder, promptWindow, userInfo, translator, userRegistration);
expect(component).toBeTruthy();
});
My question now is how can I provide the second mock implementation of the service for my component?