]> git.ipfire.org Git - thirdparty/paperless-ngx.git/blob
3545bcf7c99ce226b0ba1ce21874c5ea3d84a37d
[thirdparty/paperless-ngx.git] /
1 import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'
2 import { provideHttpClientTesting } from '@angular/common/http/testing'
3 import { ComponentFixture, TestBed } from '@angular/core/testing'
4 import { FormsModule, ReactiveFormsModule } from '@angular/forms'
5 import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
6 import { PdfViewerComponent } from 'ng2-pdf-viewer'
7 import { NgxBootstrapIconsModule, allIcons } from 'ngx-bootstrap-icons'
8 import { SafeHtmlPipe } from 'src/app/pipes/safehtml.pipe'
9 import { DeletePagesConfirmDialogComponent } from './delete-pages-confirm-dialog.component'
10
11 describe('DeletePagesConfirmDialogComponent', () => {
12 let component: DeletePagesConfirmDialogComponent
13 let fixture: ComponentFixture<DeletePagesConfirmDialogComponent>
14
15 beforeEach(async () => {
16 await TestBed.configureTestingModule({
17 declarations: [DeletePagesConfirmDialogComponent, PdfViewerComponent],
18 imports: [
19 NgxBootstrapIconsModule.pick(allIcons),
20 FormsModule,
21 ReactiveFormsModule,
22 ],
23 providers: [
24 NgbActiveModal,
25 SafeHtmlPipe,
26 provideHttpClient(withInterceptorsFromDi()),
27 provideHttpClientTesting(),
28 ],
29 }).compileComponents()
30 fixture = TestBed.createComponent(DeletePagesConfirmDialogComponent)
31 component = fixture.componentInstance
32 fixture.detectChanges()
33 })
34
35 it('should return a string with comma-separated pages', () => {
36 component.pages = [1, 2, 3, 4]
37 expect(component.pagesString).toEqual('1, 2, 3, 4')
38 })
39
40 it('should update totalPages when pdf is loaded', () => {
41 component.pdfPreviewLoaded({ numPages: 5 } as any)
42 expect(component.totalPages).toEqual(5)
43 })
44
45 it('should update checks when page is rendered', () => {
46 const event = {
47 target: document.createElement('div'),
48 detail: { pageNumber: 1 },
49 } as any
50 component.pageRendered(event)
51 expect(component['checks'].length).toEqual(1)
52 })
53
54 it('should update pages when page check is changed', () => {
55 component.pageCheckChanged(1)
56 expect(component.pages).toEqual([1])
57 component.pageCheckChanged(1)
58 expect(component.pages).toEqual([])
59 })
60 })