mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-10 19:43:04 +00:00
#150 Grid element testing
This commit is contained in:
@@ -5,6 +5,7 @@ import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { RouterStub } from '../../testing/router-stub';
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { Collection } from '../../../core/shared/collection.model';
|
||||
|
||||
let collectionGridElementComponent: CollectionGridElementComponent;
|
||||
let fixture: ComponentFixture<CollectionGridElementComponent>;
|
||||
@@ -16,6 +17,15 @@ const activatedRouteStub = {
|
||||
scope: scopeParam
|
||||
})
|
||||
};
|
||||
let mockCollection: Collection = Object.assign(new Collection(), {
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.description.abstract',
|
||||
language: 'en_US',
|
||||
value: 'Short description'
|
||||
}]
|
||||
});
|
||||
let createdGridElementComponent:CollectionGridElementComponent= new CollectionGridElementComponent(mockCollection);
|
||||
|
||||
describe('CollectionGridElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
@@ -24,7 +34,7 @@ describe('CollectionGridElementComponent', () => {
|
||||
providers: [
|
||||
{ provide: ActivatedRoute, useValue: activatedRouteStub },
|
||||
{ provide: Router, useClass: RouterStub },
|
||||
{ provide: 'objectElementProvider', useFactory: (collectionGridElementComponent)}
|
||||
{ provide: 'objectElementProvider', useValue: (createdGridElementComponent)}
|
||||
],
|
||||
|
||||
schemas: [ NO_ERRORS_SCHEMA ]
|
||||
@@ -33,11 +43,19 @@ describe('CollectionGridElementComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(CollectionGridElementComponent);
|
||||
collectionGridElementComponent = fixture.componentInstance;
|
||||
|
||||
}));
|
||||
|
||||
it('should show the collection cards in the grid element',()=>{
|
||||
expect(fixture.debugElement.query(By.css('ds-collection-grid-element'))).toBeDefined();
|
||||
})
|
||||
});
|
||||
|
||||
it('should only show the description if "short description" metadata is present',()=>{
|
||||
let descriptionText = expect(fixture.debugElement.query(By.css('p.card-text')));
|
||||
|
||||
if(mockCollection.shortDescription.length>0){
|
||||
expect(descriptionText).toBeDefined();
|
||||
}else{
|
||||
expect(descriptionText).not.toBeDefined();
|
||||
}
|
||||
});
|
||||
})
|
||||
|
Reference in New Issue
Block a user