mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 23:43:01 +00:00
80195: Fix ItemMoveComponent unit tests
This commit is contained in:
@@ -49,7 +49,9 @@ describe('ItemMoveComponent', () => {
|
|||||||
name: 'Test collection 2'
|
name: 'Test collection 2'
|
||||||
});
|
});
|
||||||
|
|
||||||
const mockItemDataService = jasmine.createSpyObj({
|
let itemDataService;
|
||||||
|
|
||||||
|
const mockItemDataServiceSuccess = jasmine.createSpyObj({
|
||||||
moveToCollection: createSuccessfulRemoteDataObject$(collection1),
|
moveToCollection: createSuccessfulRemoteDataObject$(collection1),
|
||||||
findById: createSuccessfulRemoteDataObject$(mockItem),
|
findById: createSuccessfulRemoteDataObject$(mockItem),
|
||||||
});
|
});
|
||||||
@@ -86,8 +88,9 @@ describe('ItemMoveComponent', () => {
|
|||||||
|
|
||||||
const notificationsServiceStub = new NotificationsServiceStub();
|
const notificationsServiceStub = new NotificationsServiceStub();
|
||||||
|
|
||||||
describe('ItemMoveComponent success', () => {
|
const init = (mockItemDataService) => {
|
||||||
beforeEach(() => {
|
itemDataService = mockItemDataService;
|
||||||
|
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [CommonModule, FormsModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule],
|
imports: [CommonModule, FormsModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule],
|
||||||
declarations: [ItemMoveComponent],
|
declarations: [ItemMoveComponent],
|
||||||
@@ -105,6 +108,11 @@ describe('ItemMoveComponent', () => {
|
|||||||
fixture = TestBed.createComponent(ItemMoveComponent);
|
fixture = TestBed.createComponent(ItemMoveComponent);
|
||||||
comp = fixture.componentInstance;
|
comp = fixture.componentInstance;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('ItemMoveComponent success', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
init(mockItemDataServiceSuccess);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get current url ', () => {
|
it('should get current url ', () => {
|
||||||
@@ -128,7 +136,7 @@ describe('ItemMoveComponent', () => {
|
|||||||
comp.selectedCollection = collection1;
|
comp.selectedCollection = collection1;
|
||||||
comp.moveToCollection();
|
comp.moveToCollection();
|
||||||
|
|
||||||
expect(mockItemDataService.moveToCollection).toHaveBeenCalledWith('item-id', collection1);
|
expect(itemDataService.moveToCollection).toHaveBeenCalledWith('item-id', collection1);
|
||||||
});
|
});
|
||||||
it('should call notificationsService success message on success', () => {
|
it('should call notificationsService success message on success', () => {
|
||||||
comp.moveToCollection();
|
comp.moveToCollection();
|
||||||
@@ -140,22 +148,7 @@ describe('ItemMoveComponent', () => {
|
|||||||
|
|
||||||
describe('ItemMoveComponent fail', () => {
|
describe('ItemMoveComponent fail', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
init(mockItemDataServiceFail);
|
||||||
imports: [CommonModule, FormsModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule],
|
|
||||||
declarations: [ItemMoveComponent],
|
|
||||||
providers: [
|
|
||||||
{ provide: ActivatedRoute, useValue: routeStub },
|
|
||||||
{ provide: Router, useValue: routerStub },
|
|
||||||
{ provide: ItemDataService, useValue: mockItemDataServiceFail },
|
|
||||||
{ provide: NotificationsService, useValue: notificationsServiceStub },
|
|
||||||
{ provide: SearchService, useValue: mockSearchService },
|
|
||||||
], schemas: [
|
|
||||||
CUSTOM_ELEMENTS_SCHEMA
|
|
||||||
]
|
|
||||||
}).compileComponents();
|
|
||||||
fixture = TestBed.createComponent(ItemMoveComponent);
|
|
||||||
comp = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call notificationsService error message on fail', () => {
|
it('should call notificationsService error message on fail', () => {
|
||||||
|
Reference in New Issue
Block a user