1 import { ComponentFixture, TestBed } from '@angular/core/testing'
2 import { DeletePagesConfirmDialogComponent } from './delete-pages-confirm-dialog.component'
3 import { provideHttpClientTesting } from '@angular/common/http/testing'
4 import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
5 import { NgxBootstrapIconsModule, allIcons } from 'ngx-bootstrap-icons'
6 import { SafeHtmlPipe } from 'src/app/pipes/safehtml.pipe'
7 import { FormsModule, ReactiveFormsModule } from '@angular/forms'
8 import { PdfViewerComponent } from 'ng2-pdf-viewer'
9 import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'
11 describe('DeletePagesConfirmDialogComponent', () => {
12 let component: DeletePagesConfirmDialogComponent
13 let fixture: ComponentFixture<DeletePagesConfirmDialogComponent>
15 beforeEach(async () => {
16 await TestBed.configureTestingModule({
17 declarations: [DeletePagesConfirmDialogComponent, PdfViewerComponent],
19 NgxBootstrapIconsModule.pick(allIcons),
26 provideHttpClient(withInterceptorsFromDi()),
27 provideHttpClientTesting(),
29 }).compileComponents()
30 fixture = TestBed.createComponent(DeletePagesConfirmDialogComponent)
31 component = fixture.componentInstance
32 fixture.detectChanges()
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')
40 it('should update totalPages when pdf is loaded', () => {
41 component.pdfPreviewLoaded({ numPages: 5 } as any)
42 expect(component.totalPages).toEqual(5)
45 it('should update checks when page is rendered', () => {
47 target: document.createElement('div'),
48 detail: { pageNumber: 1 },
50 component.pageRendered(event)
51 expect(component['checks'].length).toEqual(1)
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([])