From a2c9e0254cde1b9382b175eb9e2a58906ea5a5fe Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Tue, 15 Oct 2024 13:05:06 -0700 Subject: [PATCH] Update preview-popup.component.spec.ts --- .../preview-popup.component.spec.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src-ui/src/app/components/common/preview-popup/preview-popup.component.spec.ts b/src-ui/src/app/components/common/preview-popup/preview-popup.component.spec.ts index 671541404..0395e2f5a 100644 --- a/src-ui/src/app/components/common/preview-popup/preview-popup.component.spec.ts +++ b/src-ui/src/app/components/common/preview-popup/preview-popup.component.spec.ts @@ -7,7 +7,7 @@ import { SettingsService } from 'src/app/services/settings.service' import { SETTINGS_KEYS } from 'src/app/data/ui-settings' import { provideHttpClientTesting } from '@angular/common/http/testing' import { DocumentService } from 'src/app/services/rest/document.service' -import { NgxBootstrapIconsModule, allIcons } from 'ngx-bootstrap-icons' +import { NgxBootstrapIconsModule, allIcons, archive } from 'ngx-bootstrap-icons' import { PdfViewerModule } from 'ng2-pdf-viewer' import { HttpClient, @@ -21,6 +21,8 @@ const doc = { title: 'Document 10', content: 'Cupcake ipsum dolor sit amet ice cream.', original_file_name: 'sample.pdf', + archived_file_name: 'sample.pdf', + mime_type: 'application/pdf', } describe('PreviewPopupComponent', () => { @@ -47,18 +49,16 @@ describe('PreviewPopupComponent', () => { .mockImplementation((id) => doc.original_file_name) fixture = TestBed.createComponent(PreviewPopupComponent) component = fixture.componentInstance - component.document = doc + component.document = { ...doc } fixture.detectChanges() }) - it('should guess if file is pdf by file name', () => { - expect(component.isPdf).toBeTruthy() - component.document.archived_file_name = 'sample.pdf' + it('should correctly report if document is pdf', () => { expect(component.isPdf).toBeTruthy() + component.document.mime_type = 'application/msword' + expect(component.isPdf).toBeTruthy() // still has archive file component.document.archived_file_name = undefined - component.document.original_file_name = 'sample.txt' expect(component.isPdf).toBeFalsy() - component.document.original_file_name = 'sample.pdf' }) it('should return settings for native PDF viewer', () => { @@ -91,6 +91,8 @@ describe('PreviewPopupComponent', () => { it('should fall back to object for non-pdf', () => { component.document.original_file_name = 'sample.png' + component.document.mime_type = 'image/png' + component.document.archived_file_name = undefined fixture.detectChanges() expect(fixture.debugElement.query(By.css('object'))).not.toBeNull() })