authorized-collection-selector.component.spec.ts (dspace-angular-dspace-7.0) | : | authorized-collection-selector.component.spec.ts (dspace-angular-dspace-7.1) | ||
---|---|---|---|---|
skipping to change at line 29 | skipping to change at line 29 | |||
let collectionService; | let collectionService; | |||
let collection; | let collection; | |||
let notificationsService: NotificationsService; | let notificationsService: NotificationsService; | |||
beforeEach(waitForAsync(() => { | beforeEach(waitForAsync(() => { | |||
collection = Object.assign(new Collection(), { | collection = Object.assign(new Collection(), { | |||
id: 'authorized-collection' | id: 'authorized-collection' | |||
}); | }); | |||
collectionService = jasmine.createSpyObj('collectionService', { | collectionService = jasmine.createSpyObj('collectionService', { | |||
getAuthorizedCollection: createSuccessfulRemoteDataObject$(createPaginated | getAuthorizedCollection: createSuccessfulRemoteDataObject$(createPaginated | |||
List([collection])) | List([collection])), | |||
getAuthorizedCollectionByEntityType: createSuccessfulRemoteDataObject$(cre | ||||
atePaginatedList([collection])) | ||||
}); | }); | |||
notificationsService = jasmine.createSpyObj('notificationsService', ['error' ]); | notificationsService = jasmine.createSpyObj('notificationsService', ['error' ]); | |||
TestBed.configureTestingModule({ | TestBed.configureTestingModule({ | |||
declarations: [AuthorizedCollectionSelectorComponent, VarDirective], | declarations: [AuthorizedCollectionSelectorComponent, VarDirective], | |||
imports: [TranslateModule.forRoot(), RouterTestingModule.withRoutes([])], | imports: [TranslateModule.forRoot(), RouterTestingModule.withRoutes([])], | |||
providers: [ | providers: [ | |||
{ provide: SearchService, useValue: {} }, | { provide: SearchService, useValue: {} }, | |||
{ provide: CollectionDataService, useValue: collectionService }, | { provide: CollectionDataService, useValue: collectionService }, | |||
{ provide: NotificationsService, useValue: notificationsService }, | { provide: NotificationsService, useValue: notificationsService }, | |||
], | ], | |||
skipping to change at line 52 | skipping to change at line 53 | |||
})); | })); | |||
beforeEach(() => { | beforeEach(() => { | |||
fixture = TestBed.createComponent(AuthorizedCollectionSelectorComponent); | fixture = TestBed.createComponent(AuthorizedCollectionSelectorComponent); | |||
component = fixture.componentInstance; | component = fixture.componentInstance; | |||
component.types = [DSpaceObjectType.COLLECTION]; | component.types = [DSpaceObjectType.COLLECTION]; | |||
fixture.detectChanges(); | fixture.detectChanges(); | |||
}); | }); | |||
describe('search', () => { | describe('search', () => { | |||
it('should call getAuthorizedCollection and return the authorized collection | describe('when has no entity type', () => { | |||
in a SearchResult', (done) => { | it('should call getAuthorizedCollection and return the authorized collecti | |||
on in a SearchResult', (done) => { | ||||
component.search('', 1).subscribe((resultRD) => { | component.search('', 1).subscribe((resultRD) => { | |||
expect(collectionService.getAuthorizedCollection).toHaveBeenCalled(); | expect(collectionService.getAuthorizedCollection).toHaveBeenCalled(); | |||
expect(resultRD.payload.page.length).toEqual(1); | expect(resultRD.payload.page.length).toEqual(1); | |||
expect(resultRD.payload.page[0].indexableObject).toEqual(collection); | expect(resultRD.payload.page[0].indexableObject).toEqual(collection); | |||
done(); | done(); | |||
}); | ||||
}); | ||||
}); | ||||
describe('when has entity type', () => { | ||||
it('should call getAuthorizedCollectionByEntityType and return the authori | ||||
zed collection in a SearchResult', (done) => { | ||||
component.entityType = 'test'; | ||||
fixture.detectChanges(); | ||||
component.search('', 1).subscribe((resultRD) => { | ||||
expect(collectionService.getAuthorizedCollectionByEntityType).toHaveBe | ||||
enCalled(); | ||||
expect(resultRD.payload.page.length).toEqual(1); | ||||
expect(resultRD.payload.page[0].indexableObject).toEqual(collection); | ||||
done(); | ||||
}); | ||||
}); | }); | |||
}); | }); | |||
}); | }); | |||
}); | }); | |||
End of changes. 4 change blocks. | ||||
6 lines changed or deleted | 25 lines changed or added |