import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ConfigService } from '@arrow/bom/config'; import { BomItemService, CartHandoverService, CoreModule, Utils } from '@arrow/bom/core'; import { CurrencyConverterPipe, SharedModule } from '@arrow/bom/shared'; import { of } from 'rxjs'; import { BomPartPriceComponent } from './bom-part-price.component'; const mockCurrencyConverterPipe: Partial = { transform: (val: number) => { return of(val); } }; describe('BomPartPriceComponent', () => { let component: BomPartPriceComponent; let fixture: ComponentFixture; const bomItemServiceSpyObj = jasmine.createSpyObj('BomItemService', ['updateUnallocatedBuyingOptions']); beforeEach(() => { const configServiceSpyObj = jasmine.createSpyObj('ConfigService', ['getTarget']); const utilsSpyObj = jasmine.createSpyObj('Utils', ['getCurrencySymbol']); TestBed.configureTestingModule({ schemas: [NO_ERRORS_SCHEMA, CUSTOM_ELEMENTS_SCHEMA], imports: [ SharedModule, // This is needed to resolve CurrencyConverterPipe instantiation issue ], declarations: [ BomPartPriceComponent ], providers: [ { provide: BomItemService, useValue: bomItemServiceSpyObj }, // Below 4 were needed to resolve CurrencyConverterPipe instantiation issue { provide: CurrencyConverterPipe, useValue: mockCurrencyConverterPipe }, { provide: CartHandoverService, useValue: {} }, { provide: ConfigService, useValue: configServiceSpyObj }, { provide: Utils, useValue: utilsSpyObj } ] }).compileComponents(); fixture = TestBed.createComponent(BomPartPriceComponent); component = fixture.componentInstance; component.item = {}; fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); });