Update preview-popup.component.spec.ts
This commit is contained in:
parent
d77cb8ec00
commit
a2c9e0254c
@ -7,7 +7,7 @@ import { SettingsService } from 'src/app/services/settings.service'
|
|||||||
import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
|
import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
|
||||||
import { provideHttpClientTesting } from '@angular/common/http/testing'
|
import { provideHttpClientTesting } from '@angular/common/http/testing'
|
||||||
import { DocumentService } from 'src/app/services/rest/document.service'
|
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 { PdfViewerModule } from 'ng2-pdf-viewer'
|
||||||
import {
|
import {
|
||||||
HttpClient,
|
HttpClient,
|
||||||
@ -21,6 +21,8 @@ const doc = {
|
|||||||
title: 'Document 10',
|
title: 'Document 10',
|
||||||
content: 'Cupcake ipsum dolor sit amet ice cream.',
|
content: 'Cupcake ipsum dolor sit amet ice cream.',
|
||||||
original_file_name: 'sample.pdf',
|
original_file_name: 'sample.pdf',
|
||||||
|
archived_file_name: 'sample.pdf',
|
||||||
|
mime_type: 'application/pdf',
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('PreviewPopupComponent', () => {
|
describe('PreviewPopupComponent', () => {
|
||||||
@ -47,18 +49,16 @@ describe('PreviewPopupComponent', () => {
|
|||||||
.mockImplementation((id) => doc.original_file_name)
|
.mockImplementation((id) => doc.original_file_name)
|
||||||
fixture = TestBed.createComponent(PreviewPopupComponent)
|
fixture = TestBed.createComponent(PreviewPopupComponent)
|
||||||
component = fixture.componentInstance
|
component = fixture.componentInstance
|
||||||
component.document = doc
|
component.document = { ...doc }
|
||||||
fixture.detectChanges()
|
fixture.detectChanges()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should guess if file is pdf by file name', () => {
|
it('should correctly report if document is pdf', () => {
|
||||||
expect(component.isPdf).toBeTruthy()
|
|
||||||
component.document.archived_file_name = 'sample.pdf'
|
|
||||||
expect(component.isPdf).toBeTruthy()
|
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.archived_file_name = undefined
|
||||||
component.document.original_file_name = 'sample.txt'
|
|
||||||
expect(component.isPdf).toBeFalsy()
|
expect(component.isPdf).toBeFalsy()
|
||||||
component.document.original_file_name = 'sample.pdf'
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should return settings for native PDF viewer', () => {
|
it('should return settings for native PDF viewer', () => {
|
||||||
@ -91,6 +91,8 @@ describe('PreviewPopupComponent', () => {
|
|||||||
|
|
||||||
it('should fall back to object for non-pdf', () => {
|
it('should fall back to object for non-pdf', () => {
|
||||||
component.document.original_file_name = 'sample.png'
|
component.document.original_file_name = 'sample.png'
|
||||||
|
component.document.mime_type = 'image/png'
|
||||||
|
component.document.archived_file_name = undefined
|
||||||
fixture.detectChanges()
|
fixture.detectChanges()
|
||||||
expect(fixture.debugElement.query(By.css('object'))).not.toBeNull()
|
expect(fixture.debugElement.query(By.css('object'))).not.toBeNull()
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user