From ce7bcfb1224abf42cb950d899c652c133cf237a1 Mon Sep 17 00:00:00 2001
From: OZGCloud <ozgcloud@mgm-tp.com>
Date: Thu, 1 Aug 2024 17:00:45 +0200
Subject: [PATCH] OZG-6314 add tests

---
 .../vertical-binary-file-list.component.html  |  9 +++++---
 ...ertical-binary-file-list.component.spec.ts | 21 ++++++++++++++++++-
 .../attachment-header.component.spec.ts       | 16 ++++++++++++++
 3 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/alfa-client/libs/binary-file/src/lib/vertical-binary-file-list/vertical-binary-file-list.component.html b/alfa-client/libs/binary-file/src/lib/vertical-binary-file-list/vertical-binary-file-list.component.html
index 187ab55187..5771196b17 100644
--- a/alfa-client/libs/binary-file/src/lib/vertical-binary-file-list/vertical-binary-file-list.component.html
+++ b/alfa-client/libs/binary-file/src/lib/vertical-binary-file-list/vertical-binary-file-list.component.html
@@ -27,10 +27,13 @@
   *ngIf="binaryFileListStateResource.resource"
   [stateResource]="binaryFileListStateResource"
 >
-  <ods-attachment-wrapper [title]="title" data-test-id="file-list">
-    <ods-attachment-header [title]="title">
+  <ods-attachment-wrapper data-test-id="file-list">
+    <ods-attachment-header
+      [title]="title"
+      *ngIf="title || archiveDownloadUri"
+      data-test-id="file-list-header"
+    >
       <alfa-download-archive-file-button-container
-        *ngIf="archiveDownloadUri"
         data-test-class="download-archive-file-button"
         [downloadUri]="archiveDownloadUri"
         action-buttons
diff --git a/alfa-client/libs/binary-file/src/lib/vertical-binary-file-list/vertical-binary-file-list.component.spec.ts b/alfa-client/libs/binary-file/src/lib/vertical-binary-file-list/vertical-binary-file-list.component.spec.ts
index a42980975b..1f6e635555 100644
--- a/alfa-client/libs/binary-file/src/lib/vertical-binary-file-list/vertical-binary-file-list.component.spec.ts
+++ b/alfa-client/libs/binary-file/src/lib/vertical-binary-file-list/vertical-binary-file-list.component.spec.ts
@@ -37,7 +37,7 @@ import {
   createBinaryFileListResource,
   createBinaryFileResource,
 } from 'libs/binary-file-shared/test/binary-file';
-import { getDataTestClassOf } from 'libs/tech-shared/test/data-test';
+import { getDataTestClassOf, getDataTestIdOf } from 'libs/tech-shared/test/data-test';
 import { MockComponent } from 'ng-mocks';
 import { BinaryFile2ContainerComponent } from '../binary-file2-container/binary-file2-container.component';
 import { DownloadArchiveFileButtonContainerComponent } from '../download-archive-file-button-container/download-archive-file-button-container.component';
@@ -48,6 +48,7 @@ describe('VerticalBinaryFileListComponent', () => {
   let fixture: ComponentFixture<VerticalBinaryFileListComponent>;
 
   const downloadArchiveFileButton: string = getDataTestClassOf('download-archive-file-button');
+  const fileListHeader: string = getDataTestIdOf('file-list-header');
 
   const binaryFile: BinaryFileResource = createBinaryFileResource();
 
@@ -109,6 +110,24 @@ describe('VerticalBinaryFileListComponent', () => {
     });
   });
 
+  describe('attchment header', () => {
+    it('should show header if there is uri or title', () => {
+      component.title = 'Title';
+
+      fixture.detectChanges();
+
+      existsAsHtmlElement(fixture, fileListHeader);
+    });
+
+    it('should not show header if there is no uri or title', () => {
+      component.title = '';
+
+      fixture.detectChanges();
+
+      notExistsAsHtmlElement(fixture, fileListHeader);
+    });
+  });
+
   describe('download archive button', () => {
     const downloadUri: ResourceUri = faker.internet.url();
 
diff --git a/alfa-client/libs/design-system/src/lib/attachment-header/attachment-header.component.spec.ts b/alfa-client/libs/design-system/src/lib/attachment-header/attachment-header.component.spec.ts
index b1484d6418..deccecf135 100644
--- a/alfa-client/libs/design-system/src/lib/attachment-header/attachment-header.component.spec.ts
+++ b/alfa-client/libs/design-system/src/lib/attachment-header/attachment-header.component.spec.ts
@@ -1,3 +1,4 @@
+import { existsAsHtmlElement, notExistsAsHtmlElement } from '@alfa-client/test-utils';
 import { ComponentFixture, TestBed } from '@angular/core/testing';
 import { AttachmentHeaderComponent } from './attachment-header.component';
 
@@ -18,4 +19,19 @@ describe('AttachmentHeaderComponent', () => {
   it('should create', () => {
     expect(component).toBeTruthy();
   });
+  describe('title', () => {
+    it('should show heading', () => {
+      component.title = 'Test';
+      fixture.detectChanges();
+
+      existsAsHtmlElement(fixture, 'h4');
+    });
+
+    it('should not show heading', () => {
+      component.title = '';
+      fixture.detectChanges();
+
+      notExistsAsHtmlElement(fixture, 'h4');
+    });
+  });
 });
-- 
GitLab