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