@@ -51,6 +51,46 @@ describe('<DatagridRow />', () => {
51
51
} ;
52
52
} ;
53
53
54
+ describe ( 'isRowExpandable' , ( ) => {
55
+ it ( 'should show the expand button if it returns true' , ( ) => {
56
+ const contextValue = { isRowExpandable : ( ) => true } ;
57
+
58
+ const { queryAllByText, getByText } = renderWithRouter (
59
+ < DatagridContextProvider value = { contextValue } >
60
+ < DatagridRow
61
+ { ...defaultProps }
62
+ rowClick = "expand"
63
+ expand = { < ExpandPanel /> }
64
+ >
65
+ < TitleField />
66
+ </ DatagridRow >
67
+ </ DatagridContextProvider >
68
+ ) ;
69
+ expect ( queryAllByText ( 'expanded' ) ) . toHaveLength ( 0 ) ;
70
+ fireEvent . click ( getByText ( 'hello' ) ) ;
71
+ expect ( queryAllByText ( 'expanded' ) ) . toHaveLength ( 0 ) ;
72
+ } ) ;
73
+
74
+ it ( 'should not show the expand button if it returns false' , ( ) => {
75
+ const contextValue = { isRowExpandable : ( ) => false } ;
76
+
77
+ const { queryAllByText, getByText } = renderWithRouter (
78
+ < DatagridContextProvider value = { contextValue } >
79
+ < DatagridRow
80
+ { ...defaultProps }
81
+ rowClick = "expand"
82
+ expand = { < ExpandPanel /> }
83
+ >
84
+ < TitleField />
85
+ </ DatagridRow >
86
+ </ DatagridContextProvider >
87
+ ) ;
88
+ expect ( queryAllByText ( 'expanded' ) ) . toHaveLength ( 0 ) ;
89
+ fireEvent . click ( getByText ( 'hello' ) ) ;
90
+ expect ( queryAllByText ( 'expanded' ) ) . toHaveLength ( 1 ) ;
91
+ } ) ;
92
+ } ) ;
93
+
54
94
describe ( 'rowClick' , ( ) => {
55
95
it ( "should redirect to edit page if the 'edit' option is selected" , ( ) => {
56
96
const { getByText, history } = renderWithRouter (
0 commit comments