mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-10 03:23:07 +00:00
71 lines
2.3 KiB
TypeScript
71 lines
2.3 KiB
TypeScript
import { CommunityListElementComponent } from './community-list-element.component';
|
|
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';
|
|
|
|
let communityListElementComponent: CommunityListElementComponent;
|
|
let fixture: ComponentFixture<CommunityListElementComponent>;
|
|
|
|
const mockCommunityWithAbstract: Community = Object.assign(new Community(), {
|
|
metadata: [
|
|
{
|
|
key: 'dc.description.abstract',
|
|
language: 'en_US',
|
|
value: 'Short description'
|
|
}]
|
|
});
|
|
|
|
const mockCommunityWithoutAbstract: Community = Object.assign(new Community(), {
|
|
metadata: [
|
|
{
|
|
key: 'dc.title',
|
|
language: 'en_US',
|
|
value: 'Test title'
|
|
}]
|
|
});
|
|
|
|
describe('CommunityListElementComponent', () => {
|
|
beforeEach(async(() => {
|
|
TestBed.configureTestingModule({
|
|
declarations: [ CommunityListElementComponent ],
|
|
providers: [
|
|
{ provide: 'objectElementProvider', useValue: (mockCommunityWithAbstract)}
|
|
],
|
|
|
|
schemas: [ NO_ERRORS_SCHEMA ]
|
|
}).overrideComponent(CommunityListElementComponent, {
|
|
set: { changeDetection: ChangeDetectionStrategy.Default }
|
|
}).compileComponents();
|
|
}));
|
|
|
|
beforeEach(async(() => {
|
|
fixture = TestBed.createComponent(CommunityListElementComponent);
|
|
communityListElementComponent = fixture.componentInstance;
|
|
}));
|
|
|
|
describe('When the community has an abstract', () => {
|
|
beforeEach(() => {
|
|
communityListElementComponent.object = mockCommunityWithAbstract;
|
|
fixture.detectChanges();
|
|
});
|
|
|
|
it('should show the description paragraph', () => {
|
|
const communityAbstractField = fixture.debugElement.query(By.css('div.abstract-text'));
|
|
expect(communityAbstractField).not.toBeNull();
|
|
});
|
|
});
|
|
|
|
describe('When the community has no abstract', () => {
|
|
beforeEach(() => {
|
|
communityListElementComponent.object = mockCommunityWithoutAbstract;
|
|
fixture.detectChanges();
|
|
});
|
|
|
|
it('should not show the description paragraph', () => {
|
|
const communityAbstractField = fixture.debugElement.query(By.css('div.abstract-text'));
|
|
expect(communityAbstractField).toBeNull();
|
|
});
|
|
});
|
|
});
|