mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-05-23 12:58:18 -05:00
Fix tests
This commit is contained in:
parent
6510acc158
commit
17af7541a1
@ -20,6 +20,8 @@ import {
|
|||||||
withInterceptorsFromDi,
|
withInterceptorsFromDi,
|
||||||
} from '@angular/common/http'
|
} from '@angular/common/http'
|
||||||
import { of, throwError } from 'rxjs'
|
import { of, throwError } from 'rxjs'
|
||||||
|
import { NgbPopoverModule } from '@ng-bootstrap/ng-bootstrap'
|
||||||
|
import { DocumentTitlePipe } from 'src/app/pipes/document-title.pipe'
|
||||||
|
|
||||||
const doc = {
|
const doc = {
|
||||||
id: 10,
|
id: 10,
|
||||||
@ -39,8 +41,12 @@ describe('PreviewPopupComponent', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
declarations: [PreviewPopupComponent, SafeUrlPipe],
|
declarations: [PreviewPopupComponent, SafeUrlPipe, DocumentTitlePipe],
|
||||||
imports: [NgxBootstrapIconsModule.pick(allIcons), PdfViewerModule],
|
imports: [
|
||||||
|
NgxBootstrapIconsModule.pick(allIcons),
|
||||||
|
PdfViewerModule,
|
||||||
|
NgbPopoverModule,
|
||||||
|
],
|
||||||
providers: [
|
providers: [
|
||||||
provideHttpClient(withInterceptorsFromDi()),
|
provideHttpClient(withInterceptorsFromDi()),
|
||||||
provideHttpClientTesting(),
|
provideHttpClientTesting(),
|
||||||
@ -75,12 +81,14 @@ describe('PreviewPopupComponent', () => {
|
|||||||
|
|
||||||
it('should render object if native PDF viewer enabled', () => {
|
it('should render object if native PDF viewer enabled', () => {
|
||||||
settingsService.set(SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER, true)
|
settingsService.set(SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER, true)
|
||||||
|
component.popover.open()
|
||||||
fixture.detectChanges()
|
fixture.detectChanges()
|
||||||
expect(fixture.debugElement.query(By.css('object'))).not.toBeNull()
|
expect(fixture.debugElement.query(By.css('object'))).not.toBeNull()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render pngx viewer if native PDF viewer disabled', () => {
|
it('should render pngx viewer if native PDF viewer disabled', () => {
|
||||||
settingsService.set(SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER, false)
|
settingsService.set(SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER, false)
|
||||||
|
component.popover.open()
|
||||||
fixture.detectChanges()
|
fixture.detectChanges()
|
||||||
expect(fixture.debugElement.query(By.css('object'))).toBeNull()
|
expect(fixture.debugElement.query(By.css('object'))).toBeNull()
|
||||||
expect(fixture.debugElement.query(By.css('pdf-viewer'))).not.toBeNull()
|
expect(fixture.debugElement.query(By.css('pdf-viewer'))).not.toBeNull()
|
||||||
@ -88,6 +96,7 @@ describe('PreviewPopupComponent', () => {
|
|||||||
|
|
||||||
it('should show lock icon on password error', () => {
|
it('should show lock icon on password error', () => {
|
||||||
settingsService.set(SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER, false)
|
settingsService.set(SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER, false)
|
||||||
|
component.popover.open()
|
||||||
component.onError({ name: 'PasswordException' })
|
component.onError({ name: 'PasswordException' })
|
||||||
fixture.detectChanges()
|
fixture.detectChanges()
|
||||||
expect(component.requiresPassword).toBeTruthy()
|
expect(component.requiresPassword).toBeTruthy()
|
||||||
@ -98,16 +107,18 @@ describe('PreviewPopupComponent', () => {
|
|||||||
component.document.original_file_name = 'sample.png'
|
component.document.original_file_name = 'sample.png'
|
||||||
component.document.mime_type = 'image/png'
|
component.document.mime_type = 'image/png'
|
||||||
component.document.archived_file_name = undefined
|
component.document.archived_file_name = undefined
|
||||||
|
component.popover.open()
|
||||||
fixture.detectChanges()
|
fixture.detectChanges()
|
||||||
expect(fixture.debugElement.query(By.css('object'))).not.toBeNull()
|
expect(fixture.debugElement.query(By.css('object'))).not.toBeNull()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should show message on error', () => {
|
it('should show message on error', () => {
|
||||||
|
component.popover.open()
|
||||||
component.onError({})
|
component.onError({})
|
||||||
fixture.detectChanges()
|
fixture.detectChanges()
|
||||||
expect(fixture.debugElement.nativeElement.textContent).toContain(
|
expect(
|
||||||
'Error loading preview'
|
fixture.debugElement.query(By.css('.popover')).nativeElement.textContent
|
||||||
)
|
).toContain('Error loading preview')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should get text content from http if appropriate', () => {
|
it('should get text content from http if appropriate', () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user