Skip to content
Snippets Groups Projects
Commit efd1356a authored by Alexander Reifschneider's avatar Alexander Reifschneider
Browse files

OZG-5977 move wrapper to binary file component

parent dd466328
Branches
Tags
1 merge request!85OZG-5977 ui styling
...@@ -23,9 +23,7 @@ ...@@ -23,9 +23,7 @@
unter der Lizenz sind dem Lizenztext zu entnehmen. unter der Lizenz sind dem Lizenztext zu entnehmen.
--> -->
<ods-attachment-wrapper>
<alfa-binary-file-list <alfa-binary-file-list
[binaryFileListStateResource]="binaryFileListStateResource$ | async" [binaryFileListStateResource]="binaryFileListStateResource$ | async"
[listOrientation]="listOrientation" [listOrientation]="listOrientation"
></alfa-binary-file-list> ></alfa-binary-file-list>
</ods-attachment-wrapper>
...@@ -34,27 +34,19 @@ import { of } from 'rxjs'; ...@@ -34,27 +34,19 @@ import { of } from 'rxjs';
import { BinaryFileListContainerComponent } from './binary-file-list-container.component'; import { BinaryFileListContainerComponent } from './binary-file-list-container.component';
import { BinaryFileListComponent } from './binary-file-list/binary-file-list.component'; import { BinaryFileListComponent } from './binary-file-list/binary-file-list.component';
import { AttachmentWrapperComponent } from '@ods/system';
describe('BinaryFileListContainerComponent', () => { describe('BinaryFileListContainerComponent', () => {
let component: BinaryFileListContainerComponent; let component: BinaryFileListContainerComponent;
let fixture: ComponentFixture<BinaryFileListContainerComponent>; let fixture: ComponentFixture<BinaryFileListContainerComponent>;
const binaryFileService: Mock<BinaryFileService> = mock(BinaryFileService); const binaryFileService: Mock<BinaryFileService> = mock(BinaryFileService);
const binaryFileStateResource: StateResource<BinaryFileResource> = createStateResource( const binaryFileStateResource: StateResource<BinaryFileResource> = createStateResource(createBinaryFileResource());
createBinaryFileResource(),
);
const resource: Resource = createDummyResource(); const resource: Resource = createDummyResource();
const linkRel: LinkRelationName = DummyLinkRel.DUMMY; const linkRel: LinkRelationName = DummyLinkRel.DUMMY;
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
declarations: [ declarations: [BinaryFileListContainerComponent, MockComponent(BinaryFileListComponent)],
BinaryFileListContainerComponent,
MockComponent(BinaryFileListComponent),
MockComponent(AttachmentWrapperComponent),
],
providers: [ providers: [
{ {
provide: BinaryFileService, provide: BinaryFileService,
...@@ -85,8 +77,10 @@ describe('BinaryFileListContainerComponent', () => { ...@@ -85,8 +77,10 @@ describe('BinaryFileListContainerComponent', () => {
describe('binary file list', () => { describe('binary file list', () => {
it('should be called with binary file state resource', () => { it('should be called with binary file state resource', () => {
const binaryFileListComponent: BinaryFileListComponent = const binaryFileListComponent: BinaryFileListComponent = getMockComponent<BinaryFileListComponent>(
getMockComponent<BinaryFileListComponent>(fixture, BinaryFileListComponent); fixture,
BinaryFileListComponent,
);
expect(binaryFileListComponent.binaryFileListStateResource).toBe(binaryFileStateResource); expect(binaryFileListComponent.binaryFileListStateResource).toBe(binaryFileStateResource);
}); });
......
...@@ -23,11 +23,13 @@ ...@@ -23,11 +23,13 @@
unter der Lizenz sind dem Lizenztext zu entnehmen. unter der Lizenz sind dem Lizenztext zu entnehmen.
--> -->
@if (binaryFileListStateResource.resource | toEmbeddedResources: binaryFileListLinkRel.FILE_LIST; as binaryFileList) {
@if (binaryFileList.length) {
<ods-attachment-wrapper data-test-id="binary-file-list-wrapper">
<div [binaryFileListOrientation]="listOrientation"> <div [binaryFileListOrientation]="listOrientation">
<alfa-binary-file2-container <alfa-binary-file2-container *ngFor="let binaryFile of binaryFileList" [file]="binaryFile" [deletable]="false">
*ngFor="let binaryFile of binaryFileListStateResource.resource | toEmbeddedResources: binaryFileListLinkRel.FILE_LIST"
[file]="binaryFile"
[deletable]="false"
>
</alfa-binary-file2-container> </alfa-binary-file2-container>
</div> </div>
</ods-attachment-wrapper>
}
}
...@@ -23,9 +23,11 @@ ...@@ -23,9 +23,11 @@
*/ */
import { BinaryFileListResource, BinaryFileResource } from '@alfa-client/binary-file-shared'; import { BinaryFileListResource, BinaryFileResource } from '@alfa-client/binary-file-shared';
import { createStateResource, StateResource, ToEmbeddedResourcesPipe } from '@alfa-client/tech-shared'; import { createStateResource, StateResource, ToEmbeddedResourcesPipe } from '@alfa-client/tech-shared';
import { getMockComponent } from '@alfa-client/test-utils'; import { existsAsHtmlElement, getMockComponent, notExistsAsHtmlElement } from '@alfa-client/test-utils';
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AttachmentWrapperComponent } from '@ods/system';
import { createBinaryFileListResource, createBinaryFileResource } from 'libs/binary-file-shared/test/binary-file'; import { createBinaryFileListResource, createBinaryFileResource } from 'libs/binary-file-shared/test/binary-file';
import { getDataTestIdOf } from 'libs/tech-shared/test/data-test';
import { MockComponent, MockDirective } from 'ng-mocks'; import { MockComponent, MockDirective } from 'ng-mocks';
import { BinaryFile2ContainerComponent } from '../../binary-file2-container/binary-file2-container.component'; import { BinaryFile2ContainerComponent } from '../../binary-file2-container/binary-file2-container.component';
import { BinaryFileListOrientationDirective } from '../../directive/binary-file-list-orientation/binary-file-list-orientation.directive'; import { BinaryFileListOrientationDirective } from '../../directive/binary-file-list-orientation/binary-file-list-orientation.directive';
...@@ -36,9 +38,11 @@ describe('BinaryFileListComponent', () => { ...@@ -36,9 +38,11 @@ describe('BinaryFileListComponent', () => {
let fixture: ComponentFixture<BinaryFileListComponent>; let fixture: ComponentFixture<BinaryFileListComponent>;
const binaryFile: BinaryFileResource = createBinaryFileResource(); const binaryFile: BinaryFileResource = createBinaryFileResource();
const binaryFileListStateResource: StateResource<BinaryFileListResource> = createStateResource( function getBinaryFileListStateResource(binaryFiles: BinaryFileResource[]): StateResource<BinaryFileListResource> {
createBinaryFileListResource([binaryFile]), return createStateResource(createBinaryFileListResource(binaryFiles));
); }
const wrapperSelector: string = getDataTestIdOf('binary-file-list-wrapper');
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
...@@ -46,13 +50,14 @@ describe('BinaryFileListComponent', () => { ...@@ -46,13 +50,14 @@ describe('BinaryFileListComponent', () => {
BinaryFileListComponent, BinaryFileListComponent,
ToEmbeddedResourcesPipe, ToEmbeddedResourcesPipe,
MockComponent(BinaryFile2ContainerComponent), MockComponent(BinaryFile2ContainerComponent),
MockComponent(AttachmentWrapperComponent),
MockDirective(BinaryFileListOrientationDirective), MockDirective(BinaryFileListOrientationDirective),
], ],
}).compileComponents(); }).compileComponents();
fixture = TestBed.createComponent(BinaryFileListComponent); fixture = TestBed.createComponent(BinaryFileListComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
component.binaryFileListStateResource = binaryFileListStateResource; component.binaryFileListStateResource = getBinaryFileListStateResource([binaryFile]);
fixture.detectChanges(); fixture.detectChanges();
}); });
...@@ -60,6 +65,22 @@ describe('BinaryFileListComponent', () => { ...@@ -60,6 +65,22 @@ describe('BinaryFileListComponent', () => {
expect(component).toBeTruthy(); expect(component).toBeTruthy();
}); });
describe('template', () => {
describe('attachment wrapper', () => {
it('should show', () => {
existsAsHtmlElement(fixture, wrapperSelector);
});
it('should hide', () => {
component.binaryFileListStateResource = getBinaryFileListStateResource([]);
fixture.detectChanges();
notExistsAsHtmlElement(fixture, wrapperSelector);
});
});
});
describe('binary file container', () => { describe('binary file container', () => {
it('should be called with file', () => { it('should be called with file', () => {
const binaryFileContainerComponent: BinaryFile2ContainerComponent = getMockComponent<BinaryFile2ContainerComponent>( const binaryFileContainerComponent: BinaryFile2ContainerComponent = getMockComponent<BinaryFile2ContainerComponent>(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment