mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
fix BitstreamFormatsComponent tests
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { BitstreamFormatsComponent } from './bitstream-formats.component';
|
||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { of, of as observableOf } from 'rxjs';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
@@ -18,14 +18,18 @@ import { BitstreamFormatSupportLevel } from '../../../core/shared/bitstream-form
|
||||
import { cold, getTestScheduler, hot } from 'jasmine-marbles';
|
||||
import { TestScheduler } from 'rxjs/testing';
|
||||
import {
|
||||
createFailedRemoteDataObject$,
|
||||
createNoContentRemoteDataObject$,
|
||||
createSuccessfulRemoteDataObject,
|
||||
createSuccessfulRemoteDataObject$,
|
||||
createFailedRemoteDataObject$
|
||||
createSuccessfulRemoteDataObject$
|
||||
} from '../../../shared/remote-data.utils';
|
||||
import { createPaginatedList } from '../../../shared/testing/utils.test';
|
||||
import { PaginationService } from '../../../core/pagination/pagination.service';
|
||||
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub';
|
||||
import { GroupDataService } from '../../../core/eperson/group-data.service';
|
||||
import { ConfigurationDataService } from '../../../core/data/configuration-data.service';
|
||||
import { Component, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { provideMockStore } from '@ngrx/store/testing';
|
||||
|
||||
describe('BitstreamFormatsComponent', () => {
|
||||
let comp: BitstreamFormatsComponent;
|
||||
@@ -91,7 +95,7 @@ describe('BitstreamFormatsComponent', () => {
|
||||
bitstreamFormatService = jasmine.createSpyObj('bitstreamFormatService', {
|
||||
findAll: observableOf(mockFormatsRD),
|
||||
find: createSuccessfulRemoteDataObject$(mockFormatsList[0]),
|
||||
getSelectedBitstreamFormats: hot('a', { a: mockFormatsList }),
|
||||
getSelectedBitstreamFormats: hot('a', {a: mockFormatsList}),
|
||||
selectBitstreamFormat: {},
|
||||
deselectBitstreamFormat: {},
|
||||
deselectAllBitstreamFormats: {},
|
||||
@@ -99,17 +103,32 @@ describe('BitstreamFormatsComponent', () => {
|
||||
clearBitStreamFormatRequests: observableOf('cleared')
|
||||
});
|
||||
|
||||
const groupDataService = jasmine.createSpyObj('groupsDataService', {
|
||||
findListByHref: createSuccessfulRemoteDataObject$(createPaginatedList([])),
|
||||
getGroupRegistryRouterLink: '',
|
||||
getUUIDFromString: '',
|
||||
});
|
||||
|
||||
|
||||
const configurationDataService = jasmine.createSpyObj('ConfigurationDataService', {
|
||||
findByPropertyName: of({payload: {value: 'test'}}),
|
||||
});
|
||||
|
||||
paginationService = new PaginationServiceStub();
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule, BitstreamFormatsComponent, PaginationComponent, EnumKeysPipe],
|
||||
providers: [
|
||||
{ provide: BitstreamFormatDataService, useValue: bitstreamFormatService },
|
||||
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) },
|
||||
{ provide: NotificationsService, useValue: notificationsServiceStub },
|
||||
{ provide: PaginationService, useValue: paginationService }
|
||||
]
|
||||
}).compileComponents();
|
||||
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule, BitstreamFormatsComponent, PaginationComponent, EnumKeysPipe],
|
||||
providers: [
|
||||
provideMockStore(),
|
||||
{provide: BitstreamFormatDataService, useValue: bitstreamFormatService},
|
||||
{provide: HostWindowService, useValue: new HostWindowServiceStub(0)},
|
||||
{provide: NotificationsService, useValue: notificationsServiceStub},
|
||||
{provide: PaginationService, useValue: paginationService},
|
||||
{provide: GroupDataService, useValue: groupDataService},
|
||||
{provide: ConfigurationDataService, useValue: configurationDataService}
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).compileComponents();
|
||||
};
|
||||
|
||||
const initBeforeEach = () => {
|
||||
@@ -211,32 +230,54 @@ describe('BitstreamFormatsComponent', () => {
|
||||
|
||||
describe('deleteFormats success', () => {
|
||||
beforeEach(waitForAsync(() => {
|
||||
notificationsServiceStub = new NotificationsServiceStub();
|
||||
notificationsServiceStub = new NotificationsServiceStub();
|
||||
|
||||
scheduler = getTestScheduler();
|
||||
scheduler = getTestScheduler();
|
||||
|
||||
bitstreamFormatService = jasmine.createSpyObj('bitstreamFormatService', {
|
||||
findAll: observableOf(mockFormatsRD),
|
||||
find: createSuccessfulRemoteDataObject$(mockFormatsList[0]),
|
||||
getSelectedBitstreamFormats: observableOf(mockFormatsList),
|
||||
selectBitstreamFormat: {},
|
||||
deselectBitstreamFormat: {},
|
||||
deselectAllBitstreamFormats: {},
|
||||
delete: createNoContentRemoteDataObject$(),
|
||||
clearBitStreamFormatRequests: observableOf('cleared')
|
||||
});
|
||||
bitstreamFormatService = jasmine.createSpyObj('bitstreamFormatService', {
|
||||
findAll: observableOf(mockFormatsRD),
|
||||
find: createSuccessfulRemoteDataObject$(mockFormatsList[0]),
|
||||
getSelectedBitstreamFormats: observableOf(mockFormatsList),
|
||||
selectBitstreamFormat: {},
|
||||
deselectBitstreamFormat: {},
|
||||
deselectAllBitstreamFormats: {},
|
||||
delete: createNoContentRemoteDataObject$(),
|
||||
clearBitStreamFormatRequests: observableOf('cleared')
|
||||
});
|
||||
|
||||
const groupDataService = jasmine.createSpyObj('groupsDataService', {
|
||||
findListByHref: createSuccessfulRemoteDataObject$(createPaginatedList([])),
|
||||
getGroupRegistryRouterLink: '',
|
||||
getUUIDFromString: '',
|
||||
});
|
||||
|
||||
const configurationDataService = jasmine.createSpyObj('ConfigurationDataService', {
|
||||
findByPropertyName: of({payload: {value: 'test'}}),
|
||||
});
|
||||
|
||||
paginationService = new PaginationServiceStub();
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule, BitstreamFormatsComponent, PaginationComponent, EnumKeysPipe],
|
||||
providers: [
|
||||
{ provide: BitstreamFormatDataService, useValue: bitstreamFormatService },
|
||||
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) },
|
||||
{ provide: NotificationsService, useValue: notificationsServiceStub },
|
||||
{ provide: PaginationService, useValue: paginationService }
|
||||
]
|
||||
}).compileComponents();
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule,
|
||||
BitstreamFormatsComponent, PaginationComponent, EnumKeysPipe],
|
||||
providers: [
|
||||
provideMockStore(),
|
||||
{provide: BitstreamFormatDataService, useValue: bitstreamFormatService},
|
||||
{provide: HostWindowService, useValue: new HostWindowServiceStub(0)},
|
||||
{provide: NotificationsService, useValue: notificationsServiceStub},
|
||||
{provide: PaginationService, useValue: paginationService},
|
||||
{provide: GroupDataService, useValue: groupDataService},
|
||||
{provide: ConfigurationDataService, useValue: configurationDataService}
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
})
|
||||
.overrideComponent(BitstreamFormatsComponent, {
|
||||
remove: {imports: [PaginationComponent]},
|
||||
add: {imports: [TestPaginationComponent]}
|
||||
})
|
||||
.compileComponents();
|
||||
}
|
||||
));
|
||||
|
||||
@@ -259,32 +300,52 @@ describe('BitstreamFormatsComponent', () => {
|
||||
|
||||
describe('deleteFormats error', () => {
|
||||
beforeEach(waitForAsync(() => {
|
||||
notificationsServiceStub = new NotificationsServiceStub();
|
||||
notificationsServiceStub = new NotificationsServiceStub();
|
||||
|
||||
scheduler = getTestScheduler();
|
||||
scheduler = getTestScheduler();
|
||||
|
||||
bitstreamFormatService = jasmine.createSpyObj('bitstreamFormatService', {
|
||||
findAll: observableOf(mockFormatsRD),
|
||||
find: createSuccessfulRemoteDataObject$(mockFormatsList[0]),
|
||||
getSelectedBitstreamFormats: observableOf(mockFormatsList),
|
||||
selectBitstreamFormat: {},
|
||||
deselectBitstreamFormat: {},
|
||||
deselectAllBitstreamFormats: {},
|
||||
delete: createFailedRemoteDataObject$(),
|
||||
clearBitStreamFormatRequests: observableOf('cleared')
|
||||
});
|
||||
bitstreamFormatService = jasmine.createSpyObj('bitstreamFormatService', {
|
||||
findAll: observableOf(mockFormatsRD),
|
||||
find: createSuccessfulRemoteDataObject$(mockFormatsList[0]),
|
||||
getSelectedBitstreamFormats: observableOf(mockFormatsList),
|
||||
selectBitstreamFormat: {},
|
||||
deselectBitstreamFormat: {},
|
||||
deselectAllBitstreamFormats: {},
|
||||
delete: createFailedRemoteDataObject$(),
|
||||
clearBitStreamFormatRequests: observableOf('cleared')
|
||||
});
|
||||
|
||||
const groupDataService = jasmine.createSpyObj('groupsDataService', {
|
||||
findListByHref: createSuccessfulRemoteDataObject$(createPaginatedList([])),
|
||||
getGroupRegistryRouterLink: '',
|
||||
getUUIDFromString: '',
|
||||
});
|
||||
|
||||
const configurationDataService = jasmine.createSpyObj('ConfigurationDataService', {
|
||||
findByPropertyName: of({payload: {value: 'test'}}),
|
||||
});
|
||||
|
||||
paginationService = new PaginationServiceStub();
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule, BitstreamFormatsComponent, PaginationComponent, EnumKeysPipe],
|
||||
providers: [
|
||||
{ provide: BitstreamFormatDataService, useValue: bitstreamFormatService },
|
||||
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) },
|
||||
{ provide: NotificationsService, useValue: notificationsServiceStub },
|
||||
{ provide: PaginationService, useValue: paginationService }
|
||||
]
|
||||
}).compileComponents();
|
||||
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule, BitstreamFormatsComponent, PaginationComponent, EnumKeysPipe],
|
||||
providers: [
|
||||
provideMockStore(),
|
||||
{provide: BitstreamFormatDataService, useValue: bitstreamFormatService},
|
||||
{provide: HostWindowService, useValue: new HostWindowServiceStub(0)},
|
||||
{provide: NotificationsService, useValue: notificationsServiceStub},
|
||||
{provide: PaginationService, useValue: paginationService},
|
||||
{provide: PaginationService, useValue: paginationService},
|
||||
{provide: GroupDataService, useValue: groupDataService},
|
||||
{provide: ConfigurationDataService, useValue: configurationDataService}
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
})
|
||||
.overrideComponent(BitstreamFormatsComponent, {
|
||||
remove: {imports: [PaginationComponent]},
|
||||
add: {imports: [TestPaginationComponent]}
|
||||
})
|
||||
.compileComponents();
|
||||
}
|
||||
));
|
||||
|
||||
@@ -304,3 +365,12 @@ describe('BitstreamFormatsComponent', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@Component({
|
||||
exportAs: 'paginationComponent',
|
||||
selector: 'ds-pagination',
|
||||
template: ``,
|
||||
standalone: true,
|
||||
})
|
||||
export class TestPaginationComponent {
|
||||
}
|
||||
|
Reference in New Issue
Block a user