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 { BitstreamFormatsComponent } from './bitstream-formats.component';
|
||||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
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 { CommonModule } from '@angular/common';
|
||||||
import { RouterTestingModule } from '@angular/router/testing';
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
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 { cold, getTestScheduler, hot } from 'jasmine-marbles';
|
||||||
import { TestScheduler } from 'rxjs/testing';
|
import { TestScheduler } from 'rxjs/testing';
|
||||||
import {
|
import {
|
||||||
|
createFailedRemoteDataObject$,
|
||||||
createNoContentRemoteDataObject$,
|
createNoContentRemoteDataObject$,
|
||||||
createSuccessfulRemoteDataObject,
|
createSuccessfulRemoteDataObject,
|
||||||
createSuccessfulRemoteDataObject$,
|
createSuccessfulRemoteDataObject$
|
||||||
createFailedRemoteDataObject$
|
|
||||||
} from '../../../shared/remote-data.utils';
|
} from '../../../shared/remote-data.utils';
|
||||||
import { createPaginatedList } from '../../../shared/testing/utils.test';
|
import { createPaginatedList } from '../../../shared/testing/utils.test';
|
||||||
import { PaginationService } from '../../../core/pagination/pagination.service';
|
import { PaginationService } from '../../../core/pagination/pagination.service';
|
||||||
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub';
|
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', () => {
|
describe('BitstreamFormatsComponent', () => {
|
||||||
let comp: BitstreamFormatsComponent;
|
let comp: BitstreamFormatsComponent;
|
||||||
@@ -91,7 +95,7 @@ describe('BitstreamFormatsComponent', () => {
|
|||||||
bitstreamFormatService = jasmine.createSpyObj('bitstreamFormatService', {
|
bitstreamFormatService = jasmine.createSpyObj('bitstreamFormatService', {
|
||||||
findAll: observableOf(mockFormatsRD),
|
findAll: observableOf(mockFormatsRD),
|
||||||
find: createSuccessfulRemoteDataObject$(mockFormatsList[0]),
|
find: createSuccessfulRemoteDataObject$(mockFormatsList[0]),
|
||||||
getSelectedBitstreamFormats: hot('a', { a: mockFormatsList }),
|
getSelectedBitstreamFormats: hot('a', {a: mockFormatsList}),
|
||||||
selectBitstreamFormat: {},
|
selectBitstreamFormat: {},
|
||||||
deselectBitstreamFormat: {},
|
deselectBitstreamFormat: {},
|
||||||
deselectAllBitstreamFormats: {},
|
deselectAllBitstreamFormats: {},
|
||||||
@@ -99,17 +103,32 @@ describe('BitstreamFormatsComponent', () => {
|
|||||||
clearBitStreamFormatRequests: observableOf('cleared')
|
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();
|
paginationService = new PaginationServiceStub();
|
||||||
|
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule, BitstreamFormatsComponent, PaginationComponent, EnumKeysPipe],
|
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule, BitstreamFormatsComponent, PaginationComponent, EnumKeysPipe],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: BitstreamFormatDataService, useValue: bitstreamFormatService },
|
provideMockStore(),
|
||||||
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) },
|
{provide: BitstreamFormatDataService, useValue: bitstreamFormatService},
|
||||||
{ provide: NotificationsService, useValue: notificationsServiceStub },
|
{provide: HostWindowService, useValue: new HostWindowServiceStub(0)},
|
||||||
{ provide: PaginationService, useValue: paginationService }
|
{provide: NotificationsService, useValue: notificationsServiceStub},
|
||||||
]
|
{provide: PaginationService, useValue: paginationService},
|
||||||
}).compileComponents();
|
{provide: GroupDataService, useValue: groupDataService},
|
||||||
|
{provide: ConfigurationDataService, useValue: configurationDataService}
|
||||||
|
],
|
||||||
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
|
}).compileComponents();
|
||||||
};
|
};
|
||||||
|
|
||||||
const initBeforeEach = () => {
|
const initBeforeEach = () => {
|
||||||
@@ -211,32 +230,54 @@ describe('BitstreamFormatsComponent', () => {
|
|||||||
|
|
||||||
describe('deleteFormats success', () => {
|
describe('deleteFormats success', () => {
|
||||||
beforeEach(waitForAsync(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
notificationsServiceStub = new NotificationsServiceStub();
|
notificationsServiceStub = new NotificationsServiceStub();
|
||||||
|
|
||||||
scheduler = getTestScheduler();
|
scheduler = getTestScheduler();
|
||||||
|
|
||||||
bitstreamFormatService = jasmine.createSpyObj('bitstreamFormatService', {
|
bitstreamFormatService = jasmine.createSpyObj('bitstreamFormatService', {
|
||||||
findAll: observableOf(mockFormatsRD),
|
findAll: observableOf(mockFormatsRD),
|
||||||
find: createSuccessfulRemoteDataObject$(mockFormatsList[0]),
|
find: createSuccessfulRemoteDataObject$(mockFormatsList[0]),
|
||||||
getSelectedBitstreamFormats: observableOf(mockFormatsList),
|
getSelectedBitstreamFormats: observableOf(mockFormatsList),
|
||||||
selectBitstreamFormat: {},
|
selectBitstreamFormat: {},
|
||||||
deselectBitstreamFormat: {},
|
deselectBitstreamFormat: {},
|
||||||
deselectAllBitstreamFormats: {},
|
deselectAllBitstreamFormats: {},
|
||||||
delete: createNoContentRemoteDataObject$(),
|
delete: createNoContentRemoteDataObject$(),
|
||||||
clearBitStreamFormatRequests: observableOf('cleared')
|
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();
|
paginationService = new PaginationServiceStub();
|
||||||
|
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule, BitstreamFormatsComponent, PaginationComponent, EnumKeysPipe],
|
imports: [
|
||||||
providers: [
|
CommonModule,
|
||||||
{ provide: BitstreamFormatDataService, useValue: bitstreamFormatService },
|
RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule,
|
||||||
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) },
|
BitstreamFormatsComponent, PaginationComponent, EnumKeysPipe],
|
||||||
{ provide: NotificationsService, useValue: notificationsServiceStub },
|
providers: [
|
||||||
{ provide: PaginationService, useValue: paginationService }
|
provideMockStore(),
|
||||||
]
|
{provide: BitstreamFormatDataService, useValue: bitstreamFormatService},
|
||||||
}).compileComponents();
|
{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', () => {
|
describe('deleteFormats error', () => {
|
||||||
beforeEach(waitForAsync(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
notificationsServiceStub = new NotificationsServiceStub();
|
notificationsServiceStub = new NotificationsServiceStub();
|
||||||
|
|
||||||
scheduler = getTestScheduler();
|
scheduler = getTestScheduler();
|
||||||
|
|
||||||
bitstreamFormatService = jasmine.createSpyObj('bitstreamFormatService', {
|
bitstreamFormatService = jasmine.createSpyObj('bitstreamFormatService', {
|
||||||
findAll: observableOf(mockFormatsRD),
|
findAll: observableOf(mockFormatsRD),
|
||||||
find: createSuccessfulRemoteDataObject$(mockFormatsList[0]),
|
find: createSuccessfulRemoteDataObject$(mockFormatsList[0]),
|
||||||
getSelectedBitstreamFormats: observableOf(mockFormatsList),
|
getSelectedBitstreamFormats: observableOf(mockFormatsList),
|
||||||
selectBitstreamFormat: {},
|
selectBitstreamFormat: {},
|
||||||
deselectBitstreamFormat: {},
|
deselectBitstreamFormat: {},
|
||||||
deselectAllBitstreamFormats: {},
|
deselectAllBitstreamFormats: {},
|
||||||
delete: createFailedRemoteDataObject$(),
|
delete: createFailedRemoteDataObject$(),
|
||||||
clearBitStreamFormatRequests: observableOf('cleared')
|
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();
|
paginationService = new PaginationServiceStub();
|
||||||
|
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule, BitstreamFormatsComponent, PaginationComponent, EnumKeysPipe],
|
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule, BitstreamFormatsComponent, PaginationComponent, EnumKeysPipe],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: BitstreamFormatDataService, useValue: bitstreamFormatService },
|
provideMockStore(),
|
||||||
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) },
|
{provide: BitstreamFormatDataService, useValue: bitstreamFormatService},
|
||||||
{ provide: NotificationsService, useValue: notificationsServiceStub },
|
{provide: HostWindowService, useValue: new HostWindowServiceStub(0)},
|
||||||
{ provide: PaginationService, useValue: paginationService }
|
{provide: NotificationsService, useValue: notificationsServiceStub},
|
||||||
]
|
{provide: PaginationService, useValue: paginationService},
|
||||||
}).compileComponents();
|
{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