Skip to content
Snippets Groups Projects
Commit 4bddbb6c authored by Kristof De Langhe's avatar Kristof De Langhe
Browse files

66155: Test fixes

parent aedd4b99
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@ import { Item } from '../../../core/shared/item.model';
import { Relationship } from '../../../core/shared/item-relationships/relationship.model';
import { createSuccessfulRemoteDataObject$ } from '../../../shared/testing/utils';
import { TranslateModule } from '@ngx-translate/core';
import { VarDirective } from '../../../shared/utils/var.directive';
const itemType = 'Person';
const metadataField = 'dc.contributor.author';
......@@ -64,7 +65,7 @@ describe('MetadataRepresentationListComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [TranslateModule.forRoot()],
declarations: [MetadataRepresentationListComponent],
declarations: [MetadataRepresentationListComponent, VarDirective],
providers: [
{ provide: RelationshipService, useValue: relationshipService }
],
......@@ -93,12 +94,16 @@ describe('MetadataRepresentationListComponent', () => {
});
describe('when viewMore is called', () => {
let originalLimit;
beforeEach(() => {
// Store the original value of limit
originalLimit = comp.limit;
comp.viewMore();
});
it('should set the limit to a high number in order to retrieve all metadata representations', () => {
expect(comp.limit).toBeGreaterThanOrEqual(999);
it('should increment the limit with incrementBy', () => {
expect(comp.limit).toEqual(originalLimit + comp.incrementBy);
});
});
......@@ -108,8 +113,8 @@ describe('MetadataRepresentationListComponent', () => {
beforeEach(() => {
// Store the original value of limit
originalLimit = comp.limit;
// Set limit to a random number
comp.limit = 458;
// Increase limit with incrementBy
comp.limit = originalLimit + comp.incrementBy;
comp.viewLess();
});
......
......@@ -9,6 +9,7 @@ import { createRelationshipsObservable } from '../item-types/shared/item.compone
import { createSuccessfulRemoteDataObject$ } from '../../../shared/testing/utils';
import { RelationshipService } from '../../../core/data/relationship.service';
import { TranslateModule } from '@ngx-translate/core';
import { VarDirective } from '../../../shared/utils/var.directive';
const parentItem: Item = Object.assign(new Item(), {
bitstreams: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])),
......@@ -42,7 +43,7 @@ describe('RelatedItemsComponent', () => {
TestBed.configureTestingModule({
imports: [TranslateModule.forRoot()],
declarations: [RelatedItemsComponent],
declarations: [RelatedItemsComponent, VarDirective],
providers: [
{ provide: RelationshipService, useValue: relationshipService }
],
......@@ -71,25 +72,23 @@ describe('RelatedItemsComponent', () => {
});
it('should call relationship-service\'s getRelatedItemsByLabel with the correct arguments', () => {
expect(relationshipService.getRelatedItemsByLabel).toHaveBeenCalledWith(parentItem, relationType, comp.allOptions);
});
it('should set showingAll to true', () => {
expect(comp.showingAll).toEqual(true);
expect(relationshipService.getRelatedItemsByLabel).toHaveBeenCalledWith(parentItem, relationType, Object.assign(comp.options, { elementsPerPage: comp.limit + comp.incrementBy }));
});
});
describe('when viewLess is called', () => {
let originalLimit;
beforeEach(() => {
// Store the original value of limit
originalLimit = comp.limit;
// Increase limit with incrementBy
comp.limit = originalLimit + comp.incrementBy;
comp.viewLess();
});
it('should call relationship-service\'s getRelatedItemsByLabel with the correct arguments', () => {
expect(relationshipService.getRelatedItemsByLabel).toHaveBeenCalledWith(parentItem, relationType, comp.options);
});
it('should set showingAll to false', () => {
expect(comp.showingAll).toEqual(false);
expect(relationshipService.getRelatedItemsByLabel).toHaveBeenCalledWith(parentItem, relationType, Object.assign(comp.options, { elementsPerPage: originalLimit }));
});
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment