]> git.apps.os.sepia.ceph.com Git - ceph.git/blob
b220b59e6333720b4c5a70504ce06fbb978d6e27
[ceph.git] /
1 import { ComponentFixture, TestBed } from '@angular/core/testing';
2
3 import { TablePaginationComponent } from './table-pagination.component';
4
5 describe('TablePaginationComponent', () => {
6   let component: TablePaginationComponent;
7   let fixture: ComponentFixture<TablePaginationComponent>;
8   let element: HTMLElement;
9
10   beforeEach(async () => {
11     await TestBed.configureTestingModule({
12       declarations: [TablePaginationComponent]
13     }).compileComponents();
14   });
15
16   beforeEach(() => {
17     fixture = TestBed.createComponent(TablePaginationComponent);
18     component = fixture.componentInstance;
19     element = fixture.debugElement.nativeElement;
20     component.page = 1;
21     component.size = 10;
22     component.count = 100;
23     fixture.detectChanges();
24   });
25
26   it('should create', () => {
27     expect(component).toBeTruthy();
28   });
29
30   it('should contain valid inputs', () => {
31     expect(component.page).toEqual(1);
32     expect(component.size).toEqual(10);
33     expect(component.count).toEqual(100);
34   });
35
36   it('should change page', () => {
37     const input = element.querySelector('input');
38     input.value = '5';
39     input.dispatchEvent(new Event('input'));
40     expect(component.page).toEqual(5);
41   });
42
43   it('should disable prev button', () => {
44     const prev: HTMLButtonElement = element.querySelector('.pagination__btn_prev');
45     expect(prev.disabled).toBeTruthy();
46   });
47
48   it('should disable next button', () => {
49     const next: HTMLButtonElement = element.querySelector('.pagination__btn_next');
50     component.size = 100;
51     fixture.detectChanges();
52     expect(next.disabled).toBeTruthy();
53   });
54 });