File tree 2 files changed +31
-1
lines changed
2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ export class TuiTablePagination {
90
90
}
91
91
92
92
protected get start ( ) : number {
93
- return Math . min ( this . page * this . size , Math . max ( this . total - this . size , 0 ) ) ;
93
+ return Math . min ( this . page , Math . floor ( this . total / this . size ) ) * this . size ;
94
94
}
95
95
96
96
protected get end ( ) : number {
Original file line number Diff line number Diff line change @@ -62,4 +62,34 @@ test.describe('TablePagination', () => {
62
62
'2-[sizeOptionContent]-dropdown.png' ,
63
63
) ;
64
64
} ) ;
65
+
66
+ test . describe ( 'LinesPerPageButton' , ( ) => {
67
+ test ( 'Size is larger than total' , async ( { page} ) => {
68
+ await tuiGoto (
69
+ page ,
70
+ '/components/table-pagination/API?total=25&size=100&page=1' ,
71
+ ) ;
72
+
73
+ const documentationPage = new TuiDocumentationPagePO ( page ) ;
74
+ const tablePagination = new TuiTablePaginationPO (
75
+ documentationPage . apiPageExample . locator ( 'tui-table-pagination' ) ,
76
+ ) ;
77
+
78
+ await expect ( tablePagination . linesPerPageButton ) . toHaveText ( '1–25' ) ;
79
+ } ) ;
80
+
81
+ test ( 'Last page' , async ( { page} ) => {
82
+ await tuiGoto (
83
+ page ,
84
+ '/components/table-pagination/API?total=25&size=10&page=2' ,
85
+ ) ;
86
+
87
+ const documentationPage = new TuiDocumentationPagePO ( page ) ;
88
+ const tablePagination = new TuiTablePaginationPO (
89
+ documentationPage . apiPageExample . locator ( 'tui-table-pagination' ) ,
90
+ ) ;
91
+
92
+ await expect ( tablePagination . linesPerPageButton ) . toHaveText ( '21–25' ) ;
93
+ } ) ;
94
+ } ) ;
65
95
} ) ;
You can’t perform that action at this time.
0 commit comments