diff --git a/src/app/+item-page/edit-item-page/item-move/item-move.component.spec.ts b/src/app/+item-page/edit-item-page/item-move/item-move.component.spec.ts index 3ff76a1466..b51d83c0ae 100644 --- a/src/app/+item-page/edit-item-page/item-move/item-move.component.spec.ts +++ b/src/app/+item-page/edit-item-page/item-move/item-move.component.spec.ts @@ -60,7 +60,10 @@ describe('ItemMoveComponent', () => { const routeStub = { data: observableOf({ dso: createSuccessfulRemoteDataObject(Object.assign(new Item(), { - id: 'item1' + id: 'item1', + owningCollection: createSuccessfulRemoteDataObject$(Object.assign(new Collection(), { + id: 'originalOwningCollection', + })) })) }) }; diff --git a/src/app/shared/dso-selector/dso-selector/dso-selector.component.spec.ts b/src/app/shared/dso-selector/dso-selector/dso-selector.component.spec.ts index 9e68c0564b..2565b36f7d 100644 --- a/src/app/shared/dso-selector/dso-selector/dso-selector.component.spec.ts +++ b/src/app/shared/dso-selector/dso-selector/dso-selector.component.spec.ts @@ -92,12 +92,18 @@ describe('DSOSelectorComponent', () => { }); describe('populating listEntries', () => { - it('should not be empty', () => { - expect(component.listEntries.length).toBeGreaterThan(0); + it('should not be empty', (done) => { + component.listEntries$.subscribe((listEntries) => { + expect(listEntries.length).toBeGreaterThan(0); + done(); + }); }); - it('should contain a combination of the current DSO and first page results', () => { - expect(component.listEntries).toEqual([searchResult, ...firstPageResults]); + it('should contain a combination of the current DSO and first page results', (done) => { + component.listEntries$.subscribe((listEntries) => { + expect(listEntries).toEqual([searchResult, ...firstPageResults]); + done(); + }); }); describe('when current page increases', () => { @@ -105,8 +111,11 @@ describe('DSOSelectorComponent', () => { component.currentPage$.next(2); }); - it('should contain a combination of the current DSO, as well as first and second page results', () => { - expect(component.listEntries).toEqual([searchResult, ...firstPageResults, ...nextPageResults]); + it('should contain a combination of the current DSO, as well as first and second page results', (done) => { + component.listEntries$.subscribe((listEntries) => { + expect(listEntries).toEqual([searchResult, ...firstPageResults, ...nextPageResults]); + done(); + }); }); }); }); diff --git a/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.spec.ts b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.spec.ts index 3442b044a2..458272c606 100644 --- a/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.spec.ts +++ b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.spec.ts @@ -1,5 +1,5 @@ -import { waitForAsync, ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; -import { ChangeDetectionStrategy, ComponentFactoryResolver, NO_ERRORS_SCHEMA } from '@angular/core'; +import { ComponentFixture, fakeAsync, TestBed, tick, waitForAsync } from '@angular/core/testing'; +import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { ListableObjectComponentLoaderComponent } from './listable-object-component-loader.component'; import { ListableObject } from '../listable-object.model'; import { GenericConstructor } from '../../../../core/shared/generic-constructor'; @@ -117,17 +117,33 @@ describe('ListableObjectComponentLoaderComponent', () => { }); describe('When a reloadedObject is emitted', () => { + let listableComponent; + let reloadedObject: any; - it('should re-instantiate the listable component ', fakeAsync(() => { + beforeEach(() => { + spyOn((comp as any), 'connectInputsAndOutputs').and.returnValue(null); + spyOn((comp as any).contentChange, 'emit').and.returnValue(null); - spyOn((comp as any), 'instantiateComponent').and.returnValue(null); + listableComponent = fixture.debugElement.query(By.css('ds-item-list-element')).componentInstance; + reloadedObject = 'object'; + }); + + it('should pass it on connectInputsAndOutputs', fakeAsync(() => { + expect((comp as any).connectInputsAndOutputs).not.toHaveBeenCalled(); - const listableComponent = fixture.debugElement.query(By.css('ds-item-list-element')).componentInstance; - const reloadedObject: any = 'object'; (listableComponent as any).reloadedObject.emit(reloadedObject); tick(); - expect((comp as any).instantiateComponent).toHaveBeenCalledWith(reloadedObject); + expect((comp as any).connectInputsAndOutputs).toHaveBeenCalled(); + })); + + it('should re-emit it as a contentChange', fakeAsync(() => { + expect((comp as any).contentChange.emit).not.toHaveBeenCalled(); + + (listableComponent as any).reloadedObject.emit(reloadedObject); + tick(); + + expect((comp as any).contentChange.emit).toHaveBeenCalledWith(reloadedObject); })); });