[CST-5337] Replace Notifications broker with Quality assurance

This commit is contained in:
Luca Giamminonni
2022-07-06 17:04:11 +02:00
parent df93058881
commit d5c1b11d77
77 changed files with 1198 additions and 1198 deletions

View File

@@ -0,0 +1,68 @@
import { TestBed } from '@angular/core/testing';
import { of as observableOf } from 'rxjs';
import { QualityAssuranceSourceService } from './quality-assurance-source.service';
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
import { PageInfo } from '../../../core/shared/page-info.model';
import {
getMockQualityAssuranceSourceRestService,
qualityAssuranceSourceObjectMoreAbstract,
qualityAssuranceSourceObjectMorePid
} from '../../../shared/mocks/notifications.mock';
import { createSuccessfulRemoteDataObject } from '../../../shared/remote-data.utils';
import { cold } from 'jasmine-marbles';
import { buildPaginatedList } from '../../../core/data/paginated-list.model';
import { QualityAssuranceSourceRestService } from '../../../core/notifications/qa/source/quality-assurance-source-rest.service';
import { RequestParam } from '../../../core/cache/models/request-param.model';
import {FindListOptions} from '../../../core/data/find-list-options.model';
describe('QualityAssuranceSourceService', () => {
let service: QualityAssuranceSourceService;
let restService: QualityAssuranceSourceRestService;
let serviceAsAny: any;
let restServiceAsAny: any;
const pageInfo = new PageInfo();
const array = [ qualityAssuranceSourceObjectMorePid, qualityAssuranceSourceObjectMoreAbstract ];
const paginatedList = buildPaginatedList(pageInfo, array);
const paginatedListRD = createSuccessfulRemoteDataObject(paginatedList);
const elementsPerPage = 3;
const currentPage = 0;
beforeEach(async () => {
TestBed.configureTestingModule({
providers: [
{ provide: QualityAssuranceSourceRestService, useClass: getMockQualityAssuranceSourceRestService },
{ provide: QualityAssuranceSourceService, useValue: service }
]
}).compileComponents();
});
beforeEach(() => {
restService = TestBed.get(QualityAssuranceSourceRestService);
restServiceAsAny = restService;
restServiceAsAny.getSources.and.returnValue(observableOf(paginatedListRD));
service = new QualityAssuranceSourceService(restService);
serviceAsAny = service;
});
describe('getSources', () => {
it('Should proxy the call to qualityAssuranceSourceRestService.getSources', () => {
const sortOptions = new SortOptions('name', SortDirection.ASC);
const findListOptions: FindListOptions = {
elementsPerPage: elementsPerPage,
currentPage: currentPage,
sort: sortOptions
};
const result = service.getSources(elementsPerPage, currentPage);
expect((service as any).qualityAssuranceSourceRestService.getSources).toHaveBeenCalledWith(findListOptions);
});
it('Should return a paginated list of Quality Assurance Source', () => {
const expected = cold('(a|)', {
a: paginatedList
});
const result = service.getSources(elementsPerPage, currentPage);
expect(result).toBeObservable(expected);
});
});
});