1 import { NO_ERRORS_SCHEMA } from '@angular/core';
2 import { ComponentFixture } from '@angular/core/testing';
3 import { NgxDatatableModule } from '@swimlane/ngx-datatable';
4 import { SdcUiServices } from 'onap-ui-angular';
5 import { ConfigureFn, configureTests } from '../../../../../../jest/test-config.helper';
6 import { DistributionService } from '../distribution.service';
7 import { DistributionComponentTableComponent } from './distribution-component-table.component';
9 describe('DistributionComponentTableComponent', () => {
10 let fixture: ComponentFixture<DistributionComponentTableComponent>;
11 let distibutionServiceMock: Partial<DistributionService>;
13 const mockComponentsForDistribution = ['Consumer1', 'Consumer2'];
17 distibutionServiceMock = {
18 getComponentsByDistributionID: jest.fn().mockReturnValue(mockComponentsForDistribution),
19 getArtifactstByDistributionIDAndComponentsName: jest.fn(),
20 getArtifactsForDistributionIDAndComponentByStatus: jest.fn()
23 const configure: ConfigureFn = (testBed) => {
24 testBed.configureTestingModule({
25 declarations: [DistributionComponentTableComponent],
26 imports: [NgxDatatableModule],
27 schemas: [NO_ERRORS_SCHEMA],
29 {provide: DistributionService, useValue: distibutionServiceMock},
30 {provide: SdcUiServices.ModalService, useValue: {}}
35 configureTests(configure).then((testBed) => {
36 fixture = testBed.createComponent(DistributionComponentTableComponent);
41 it('Once the Distribution Component Table Component is created - components will keep the relevant components for a specific distributionID', async () => {
42 await fixture.componentInstance.ngOnInit();
43 expect(fixture.componentInstance.components.length).toBe(2);
44 expect(fixture.componentInstance.components[0]).toBe('Consumer1');
45 expect(fixture.componentInstance.components[1]).toBe('Consumer2');