File tree Expand file tree Collapse file tree 2 files changed +13
-39
lines changed
src/components/ClientTable Expand file tree Collapse file tree 2 files changed +13
-39
lines changed Original file line number Diff line number Diff line change 1- import { range } from '@douglasneuroinformatics/libjs' ;
21import { render , screen } from '@testing-library/react' ;
32import { describe , expect , it } from 'vitest' ;
43
54import { ClientTable } from './ClientTable' ;
65
76const TEST_ID = 'ClientTable' ;
7+ const FIRST_BUTTON_ID = 'first-page-button' ;
8+ const PREVIOUS_BUTTON_ID = 'previous-page-button' ;
9+ const NEXT_BUTTON_ID = 'next-page-button' ;
10+ const LAST_BUTTON_ID = 'last-page-button' ;
811
912describe ( 'ClientTable' , ( ) => {
1013 it ( 'should render' , ( ) => {
11- render (
12- < ClientTable
13- columnDropdownOptions = { [
14- {
15- label : 'Delete' ,
16- onSelection : ( column ) => {
17- return column . label ;
18- }
19- }
20- ] }
21- columns = { [
22- {
23- field : 'f1' ,
24- label : 'Field 1'
25- } ,
26- {
27- field : 'f2' ,
28- label : 'Field 2'
29- } ,
30- {
31- field : 'f3' ,
32- label : 'Field 3'
33- }
34- ] }
35- data = { [
36- {
37- f1 : 1 ,
38- f2 : range ( 1000 ) . join ( ', ' ) ,
39- f3 : 3
40- }
41- ] }
42- minRows = { 10 }
43- noWrap = { true }
44- onEntryClick = { ( entry ) => {
45- return entry ;
46- } }
47- />
48- ) ;
14+ render ( < ClientTable columns = { [ ] } data = { [ ] } minRows = { 10 } noWrap = { true } /> ) ;
4915 expect ( screen . getByTestId ( TEST_ID ) ) . toBeInTheDocument ( ) ;
16+ expect ( screen . getByTestId ( FIRST_BUTTON_ID ) ) . toBeInTheDocument ( ) ;
17+ expect ( screen . getByTestId ( PREVIOUS_BUTTON_ID ) ) . toBeInTheDocument ( ) ;
18+ expect ( screen . getByTestId ( NEXT_BUTTON_ID ) ) . toBeInTheDocument ( ) ;
19+ expect ( screen . getByTestId ( LAST_BUTTON_ID ) ) . toBeInTheDocument ( ) ;
5020 } ) ;
5121} ) ;
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ export const ClientTablePagination = ({
2727 </ div >
2828 < div className = "flex flex-1 justify-between gap-3 sm:justify-end" >
2929 < Button
30+ data-testid = "first-page-button"
3031 disabled = { currentPage === 1 }
3132 type = "button"
3233 variant = "outline"
@@ -37,6 +38,7 @@ export const ClientTablePagination = ({
3738 { t ( 'pagination.firstPage' ) }
3839 </ Button >
3940 < Button
41+ data-testid = "previous-page-button"
4042 disabled = { currentPage === 1 }
4143 type = "button"
4244 variant = "outline"
@@ -47,6 +49,7 @@ export const ClientTablePagination = ({
4749 { t ( 'pagination.previous' ) }
4850 </ Button >
4951 < Button
52+ data-testid = "next-page-button"
5053 disabled = { currentPage === pageCount }
5154 type = "button"
5255 variant = "outline"
@@ -57,6 +60,7 @@ export const ClientTablePagination = ({
5760 { t ( 'pagination.next' ) }
5861 </ Button >
5962 < Button
63+ data-testid = "last-page-button"
6064 disabled = { currentPage === pageCount }
6165 type = "button"
6266 variant = "outline"
You can’t perform that action at this time.
0 commit comments