Skip to content
Snippets Groups Projects
Commit 43d44b88 authored by OZGCloud's avatar OZGCloud
Browse files

Merge branch 'master' into OZG-768_umbau_binary_file_list_component

parents 98a1c547 609e5d58
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,9 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MockComponent } from 'ng-mocks';
import { KommentarListInVorgangComponent } from './kommentar-list-in-vorgang.component';
import { KommentarListItemInVorgangComponent } from './kommentar-list-item-in-vorgang/kommentar-list-item-in-vorgang.component';
import { createEmptyStateResource, createStateResource, EMPTY_ARRAY } from '@goofy-client/tech-shared';
import { createKommentarListResource } from '../../../../../kommentar-shared/test/kommentar';
import { KommentarListLinkRel } from '@goofy-client/kommentar-shared';
describe('KommentarListInVorgangComponent', () => {
let component: KommentarListInVorgangComponent;
......@@ -47,4 +50,27 @@ describe('KommentarListInVorgangComponent', () => {
it('should create', () => {
expect(component).toBeTruthy();
});
describe('getKommentare', () => {
it('should return empty array if state resource is null', () => {
component.kommentarListStateResource = null;
expect(component.getKommentare()).toEqual(EMPTY_ARRAY);
});
it('should return empty array if resource is null', () => {
component.kommentarListStateResource = createEmptyStateResource();
expect(component.getKommentare()).toEqual(EMPTY_ARRAY);
});
it('should return embedded resource', () => {
const kommentareListResource = createKommentarListResource();
component.kommentarListStateResource = createStateResource(kommentareListResource);
expect(component.getKommentare()).toEqual(
kommentareListResource._embedded[KommentarListLinkRel.KOMMENTAR_LIST]);
})
});
});
......@@ -23,9 +23,8 @@
*/
import { Component, Input, OnChanges } from '@angular/core';
import { KommentarListResource, KommentarResource } from '@goofy-client/kommentar-shared';
import { getEmbeddedResource } from '@ngxp/rest';
import { KommentarListLinkRel } from 'libs/kommentar-shared/src/lib/kommentar.linkrel';
import { EMPTY_ARRAY, StateResource } from "@goofy-client/tech-shared";
import { getEmbeddedResources, StateResource } from "@goofy-client/tech-shared";
@Component({
selector: 'goofy-client-kommentar-list-in-vorgang',
......@@ -43,10 +42,8 @@ export class KommentarListInVorgangComponent implements OnChanges {
}
getKommentare(): KommentarResource[] {
return this.kommentarListStateResource
? getEmbeddedResource(
this.kommentarListStateResource.resource,
KommentarListLinkRel.KOMMENTAR_LIST)
: EMPTY_ARRAY;
return getEmbeddedResources(
this.kommentarListStateResource,
KommentarListLinkRel.KOMMENTAR_LIST);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment