This commit is contained in:
Dániel Péter Sipos
2020-11-13 16:08:52 +01:00
parent cb3131e31b
commit bb1d863470
8 changed files with 43 additions and 4 deletions

View File

@@ -13,6 +13,7 @@ import { Collection } from '../../../../../core/shared/collection.model';
import { By } from '@angular/platform-browser';
import { RouterTestingModule } from '@angular/router/testing';
import { getCollectionEditRoute } from '../../../../../+collection-page/collection-page-routing-paths';
import { LinkService } from '../../../../../core/cache/builders/link.service';
describe('CollectionAdminSearchResultGridElementComponent', () => {
let component: CollectionAdminSearchResultGridElementComponent;
@@ -26,6 +27,11 @@ describe('CollectionAdminSearchResultGridElementComponent', () => {
searchResult.indexableObject = new Collection();
searchResult.indexableObject.uuid = id;
}
const linkService = jasmine.createSpyObj('linkService', {
resolveLink: {}
});
beforeEach(async(() => {
init();
TestBed.configureTestingModule({
@@ -39,6 +45,7 @@ describe('CollectionAdminSearchResultGridElementComponent', () => {
providers: [
{ provide: TruncatableService, useValue: mockTruncatableService },
{ provide: BitstreamDataService, useValue: {} },
{ provide: LinkService, useValue: linkService}
]
})
.compileComponents();

View File

@@ -16,6 +16,7 @@ import { CommunitySearchResult } from '../../../../../shared/object-collection/s
import { Community } from '../../../../../core/shared/community.model';
import { CommunityAdminSearchResultListElementComponent } from '../../admin-search-result-list-element/community-search-result/community-admin-search-result-list-element.component';
import { getCommunityEditRoute } from '../../../../../+community-page/community-page-routing-paths';
import { LinkService } from '../../../../../core/cache/builders/link.service';
describe('CommunityAdminSearchResultGridElementComponent', () => {
let component: CommunityAdminSearchResultGridElementComponent;
@@ -29,6 +30,11 @@ describe('CommunityAdminSearchResultGridElementComponent', () => {
searchResult.indexableObject = new Community();
searchResult.indexableObject.uuid = id;
}
const linkService = jasmine.createSpyObj('linkService', {
resolveLink: {}
});
beforeEach(async(() => {
init();
TestBed.configureTestingModule({
@@ -42,6 +48,7 @@ describe('CommunityAdminSearchResultGridElementComponent', () => {
providers: [
{ provide: TruncatableService, useValue: mockTruncatableService },
{ provide: BitstreamDataService, useValue: {} },
{ provide: LinkService, useValue: linkService}
],
schemas: [NO_ERRORS_SCHEMA]
})

View File

@@ -3,10 +3,16 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { By } from '@angular/platform-browser';
import { Collection } from '../../../core/shared/collection.model';
import { of } from 'rxjs';
import { createSuccessfulRemoteDataObject$ } from '../../remote-data.utils';
import { Bitstream } from '../../../core/shared/bitstream.model';
import { LinkService } from '../../../core/cache/builders/link.service';
let collectionGridElementComponent: CollectionGridElementComponent;
let fixture: ComponentFixture<CollectionGridElementComponent>;
const mockCollectionWithAbstract: Collection = Object.assign(new Collection(), {
metadata: {
'dc.description.abstract': [
@@ -29,12 +35,17 @@ const mockCollectionWithoutAbstract: Collection = Object.assign(new Collection()
}
});
const linkService = jasmine.createSpyObj('linkService', {
resolveLink: mockCollectionWithAbstract
});
describe('CollectionGridElementComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CollectionGridElementComponent ],
providers: [
{ provide: 'objectElementProvider', useValue: (mockCollectionWithAbstract)}
{ provide: 'objectElementProvider', useValue: (mockCollectionWithAbstract)},
{ provide: LinkService, useValue: linkService}
],
schemas: [ NO_ERRORS_SCHEMA ]

View File

@@ -3,6 +3,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { By } from '@angular/platform-browser';
import { Community } from '../../../core/shared/community.model';
import { LinkService } from '../../../core/cache/builders/link.service';
let communityGridElementComponent: CommunityGridElementComponent;
let fixture: ComponentFixture<CommunityGridElementComponent>;
@@ -29,12 +30,17 @@ const mockCommunityWithoutAbstract: Community = Object.assign(new Community(), {
}
});
const linkService = jasmine.createSpyObj('linkService', {
resolveLink: mockCommunityWithAbstract
});
describe('CommunityGridElementComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CommunityGridElementComponent ],
providers: [
{ provide: 'objectElementProvider', useValue: (mockCommunityWithAbstract)}
{ provide: 'objectElementProvider', useValue: (mockCommunityWithAbstract)},
{ provide: LinkService, useValue: linkService}
],
schemas: [ NO_ERRORS_SCHEMA ]

View File

@@ -19,6 +19,7 @@ import { TruncatableService } from '../../../truncatable/truncatable.service';
import { TruncatePipe } from '../../../utils/truncate.pipe';
import { CollectionSearchResultGridElementComponent } from './collection-search-result-grid-element.component';
import { BitstreamFormatDataService } from '../../../../core/data/bitstream-format-data.service';
import { LinkService } from '../../../../core/cache/builders/link.service';
let collectionSearchResultGridElementComponent: CollectionSearchResultGridElementComponent;
let fixture: ComponentFixture<CollectionSearchResultGridElementComponent>;
@@ -52,6 +53,9 @@ mockCollectionWithoutAbstract.indexableObject = Object.assign(new Collection(),
]
}
});
const linkService = jasmine.createSpyObj('linkService', {
resolveLink: mockCollectionWithAbstract
});
describe('CollectionSearchResultGridElementComponent', () => {
beforeEach(async(() => {
@@ -72,6 +76,7 @@ describe('CollectionSearchResultGridElementComponent', () => {
{ provide: DSOChangeAnalyzer, useValue: {} },
{ provide: DefaultChangeAnalyzer, useValue: {} },
{ provide: BitstreamFormatDataService, useValue: {} },
{ provide: LinkService, useValue: linkService}
],
schemas: [ NO_ERRORS_SCHEMA ]

View File

@@ -33,7 +33,6 @@ export class CollectionSearchResultGridElementComponent extends SearchResultGrid
@Input() set dso(dso: Collection) {
this._dso = dso;
console.log('aaasdasd')
if (hasValue(this._dso) && hasNoValue(this._dso.logo)) {
this.linkService.resolveLink<Collection>(
this._dso,

View File

@@ -19,6 +19,7 @@ import { TruncatableService } from '../../../truncatable/truncatable.service';
import { TruncatePipe } from '../../../utils/truncate.pipe';
import { CommunitySearchResultGridElementComponent } from './community-search-result-grid-element.component';
import { BitstreamFormatDataService } from '../../../../core/data/bitstream-format-data.service';
import { LinkService } from '../../../../core/cache/builders/link.service';
let communitySearchResultGridElementComponent: CommunitySearchResultGridElementComponent;
let fixture: ComponentFixture<CommunitySearchResultGridElementComponent>;
@@ -52,6 +53,9 @@ mockCommunityWithoutAbstract.indexableObject = Object.assign(new Community(), {
]
}
});
const linkService = jasmine.createSpyObj('linkService', {
resolveLink: mockCommunityWithAbstract
});
describe('CommunitySearchResultGridElementComponent', () => {
beforeEach(async(() => {
@@ -72,6 +76,7 @@ describe('CommunitySearchResultGridElementComponent', () => {
{ provide: DSOChangeAnalyzer, useValue: {} },
{ provide: DefaultChangeAnalyzer, useValue: {} },
{ provide: BitstreamFormatDataService, useValue: {} },
{ provide: LinkService, useValue: linkService}
],
schemas: [ NO_ERRORS_SCHEMA ]

View File

@@ -35,7 +35,6 @@ export class CommunitySearchResultGridElementComponent extends SearchResultGridE
@Input() set dso(dso: Community) {
this._dso = dso;
console.log('aaasdasd');
if (hasValue(this._dso) && hasNoValue(this._dso.logo)) {
this.linkService.resolveLink<Community>(this._dso, followLink('logo'));
}