mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
66155: Test fixes
This commit is contained in:
@@ -7,6 +7,7 @@ import { Item } from '../../../core/shared/item.model';
|
|||||||
import { Relationship } from '../../../core/shared/item-relationships/relationship.model';
|
import { Relationship } from '../../../core/shared/item-relationships/relationship.model';
|
||||||
import { createSuccessfulRemoteDataObject$ } from '../../../shared/testing/utils';
|
import { createSuccessfulRemoteDataObject$ } from '../../../shared/testing/utils';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
import { VarDirective } from '../../../shared/utils/var.directive';
|
||||||
|
|
||||||
const itemType = 'Person';
|
const itemType = 'Person';
|
||||||
const metadataField = 'dc.contributor.author';
|
const metadataField = 'dc.contributor.author';
|
||||||
@@ -64,7 +65,7 @@ describe('MetadataRepresentationListComponent', () => {
|
|||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [TranslateModule.forRoot()],
|
imports: [TranslateModule.forRoot()],
|
||||||
declarations: [MetadataRepresentationListComponent],
|
declarations: [MetadataRepresentationListComponent, VarDirective],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: RelationshipService, useValue: relationshipService }
|
{ provide: RelationshipService, useValue: relationshipService }
|
||||||
],
|
],
|
||||||
@@ -93,12 +94,16 @@ describe('MetadataRepresentationListComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('when viewMore is called', () => {
|
describe('when viewMore is called', () => {
|
||||||
|
let originalLimit;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
// Store the original value of limit
|
||||||
|
originalLimit = comp.limit;
|
||||||
comp.viewMore();
|
comp.viewMore();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set the limit to a high number in order to retrieve all metadata representations', () => {
|
it('should increment the limit with incrementBy', () => {
|
||||||
expect(comp.limit).toBeGreaterThanOrEqual(999);
|
expect(comp.limit).toEqual(originalLimit + comp.incrementBy);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -108,8 +113,8 @@ describe('MetadataRepresentationListComponent', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
// Store the original value of limit
|
// Store the original value of limit
|
||||||
originalLimit = comp.limit;
|
originalLimit = comp.limit;
|
||||||
// Set limit to a random number
|
// Increase limit with incrementBy
|
||||||
comp.limit = 458;
|
comp.limit = originalLimit + comp.incrementBy;
|
||||||
comp.viewLess();
|
comp.viewLess();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -9,6 +9,7 @@ import { createRelationshipsObservable } from '../item-types/shared/item.compone
|
|||||||
import { createSuccessfulRemoteDataObject$ } from '../../../shared/testing/utils';
|
import { createSuccessfulRemoteDataObject$ } from '../../../shared/testing/utils';
|
||||||
import { RelationshipService } from '../../../core/data/relationship.service';
|
import { RelationshipService } from '../../../core/data/relationship.service';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
import { VarDirective } from '../../../shared/utils/var.directive';
|
||||||
|
|
||||||
const parentItem: Item = Object.assign(new Item(), {
|
const parentItem: Item = Object.assign(new Item(), {
|
||||||
bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])),
|
bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])),
|
||||||
@@ -42,7 +43,7 @@ describe('RelatedItemsComponent', () => {
|
|||||||
|
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [TranslateModule.forRoot()],
|
imports: [TranslateModule.forRoot()],
|
||||||
declarations: [RelatedItemsComponent],
|
declarations: [RelatedItemsComponent, VarDirective],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: RelationshipService, useValue: relationshipService }
|
{ provide: RelationshipService, useValue: relationshipService }
|
||||||
],
|
],
|
||||||
@@ -71,25 +72,23 @@ describe('RelatedItemsComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should call relationship-service\'s getRelatedItemsByLabel with the correct arguments', () => {
|
it('should call relationship-service\'s getRelatedItemsByLabel with the correct arguments', () => {
|
||||||
expect(relationshipService.getRelatedItemsByLabel).toHaveBeenCalledWith(parentItem, relationType, comp.allOptions);
|
expect(relationshipService.getRelatedItemsByLabel).toHaveBeenCalledWith(parentItem, relationType, Object.assign(comp.options, { elementsPerPage: comp.limit + comp.incrementBy }));
|
||||||
});
|
|
||||||
|
|
||||||
it('should set showingAll to true', () => {
|
|
||||||
expect(comp.showingAll).toEqual(true);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when viewLess is called', () => {
|
describe('when viewLess is called', () => {
|
||||||
|
let originalLimit;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
// Store the original value of limit
|
||||||
|
originalLimit = comp.limit;
|
||||||
|
// Increase limit with incrementBy
|
||||||
|
comp.limit = originalLimit + comp.incrementBy;
|
||||||
comp.viewLess();
|
comp.viewLess();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call relationship-service\'s getRelatedItemsByLabel with the correct arguments', () => {
|
it('should call relationship-service\'s getRelatedItemsByLabel with the correct arguments', () => {
|
||||||
expect(relationshipService.getRelatedItemsByLabel).toHaveBeenCalledWith(parentItem, relationType, comp.options);
|
expect(relationshipService.getRelatedItemsByLabel).toHaveBeenCalledWith(parentItem, relationType, Object.assign(comp.options, { elementsPerPage: originalLimit }));
|
||||||
});
|
|
||||||
|
|
||||||
it('should set showingAll to false', () => {
|
|
||||||
expect(comp.showingAll).toEqual(false);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user