diff --git a/src/app/shared/services/attachment.service.spec.ts b/src/app/shared/services/attachment.service.spec.ts index 4cb7f76fd..888753ec8 100644 --- a/src/app/shared/services/attachment.service.spec.ts +++ b/src/app/shared/services/attachment.service.spec.ts @@ -29,11 +29,25 @@ describe("AttachmentService", () => { }); it("should return null for non-string input", () => { - const mimeType = service.base64MimeType(null as any); + const mimeType = service.base64MimeType(null); expect(mimeType).toBeNull(); }); }); + describe("getImageUrl", () => { + it("should return the pdf icon if the file is pdf", () => { + const encoded = "data:application/pdf;base64,SGVsbG8sIFdvcmxkIQ=="; + const imageUrl = service.getImageUrl(encoded); + expect(imageUrl).toBe("assets/images/pdf-icon.svg"); + }); + + it("should return the encoded string if the file is not pdf", () => { + const encoded = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA"; + const imageUrl = service.getImageUrl(encoded); + expect(imageUrl).toBe(encoded); + }); + }); + describe("openAttachment", () => { it("should open a new window with the correct object URL", () => { const encoded = "data:text/plain;base64,SGVsbG8sIFdvcmxkIQ=="; diff --git a/src/app/shared/services/thumbnail.service.spec.ts b/src/app/shared/services/thumbnail.service.spec.ts index 9a441dfbc..fb187528d 100644 --- a/src/app/shared/services/thumbnail.service.spec.ts +++ b/src/app/shared/services/thumbnail.service.spec.ts @@ -5,6 +5,7 @@ import { ThumbnailService } from "./thumbnail.service"; import { selectDatasetsPerPage } from "state-management/selectors/datasets.selectors"; import { MockStore, provideMockStore } from "@ngrx/store/testing"; import { of, throwError } from "rxjs"; +import { AttachmentService } from "./attachment.service"; describe("ThumbnailService", () => { let service: ThumbnailService; @@ -27,6 +28,9 @@ describe("ThumbnailService", () => { provide: AppConfigService, useValue: { getConfig }, }, + { + provide: AttachmentService, + }, provideMockStore({ selectors: [ {