1 import { ComponentFixture, TestBed } from '@angular/core/testing';
3 import { TablePaginationComponent } from './table-pagination.component';
5 describe('TablePaginationComponent', () => {
6 let component: TablePaginationComponent;
7 let fixture: ComponentFixture<TablePaginationComponent>;
8 let element: HTMLElement;
10 beforeEach(async () => {
11 await TestBed.configureTestingModule({
12 declarations: [TablePaginationComponent]
13 }).compileComponents();
17 fixture = TestBed.createComponent(TablePaginationComponent);
18 component = fixture.componentInstance;
19 element = fixture.debugElement.nativeElement;
22 component.count = 100;
23 fixture.detectChanges();
26 it('should create', () => {
27 expect(component).toBeTruthy();
30 it('should contain valid inputs', () => {
31 expect(component.page).toEqual(1);
32 expect(component.size).toEqual(10);
33 expect(component.count).toEqual(100);
36 it('should change page', () => {
37 const input = element.querySelector('input');
39 input.dispatchEvent(new Event('input'));
40 expect(component.page).toEqual(5);
43 it('should disable prev button', () => {
44 const prev: HTMLButtonElement = element.querySelector('.pagination__btn_prev');
45 expect(prev.disabled).toBeTruthy();
48 it('should disable next button', () => {
49 const next: HTMLButtonElement = element.querySelector('.pagination__btn_next');
51 fixture.detectChanges();
52 expect(next.disabled).toBeTruthy();