1
  import { Http, ConnectionBackend, RequestOptions, RequestMethod, HttpModule } from '@angular/http';
  ...

 fdescribe('WidgetAdditionalPricesComponent', () => {
   let component: WidgetAdditionalPricesComponent;
   let fixture: ComponentFixture<WidgetAdditionalPricesComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
  providers: [ChainService, Http, ConnectionBackend, RequestOptions],
  declarations: [WidgetAdditionalPricesComponent, WidgetToolbarComponent, MaxLengthPipe, DropdownComponent, DatexPipe],
  imports: [HttpModule]
})
  .compileComponents();
 }));

beforeEach(() => {
   fixture = TestBed.createComponent(WidgetAdditionalPricesComponent);
   component = fixture.componentInstance;
   fixture.detectChanges();
});

it('should create', () => {
   expect(component).toBeTruthy();
});

it('test color of zavods', () => {
    let color = component.getColorName('ОНПЗ');
    expect(color).toBe('blue');
  });
});

Выходит следующая ошибка: Failed: Can't resolve all parameters for RequestOptions: (?). Что сделать? Вроде добавил RequestOptions. Спасибо

1 ответ 1

0

Вы указали "RequestOptions" в поле "providers" в то время, как этот класс не является сервисом(Injectable), а просто утилитарным классом для взаимодействия с Http сервисом. Если убрать его из декларации тест-модуля, то должно заработать

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.