@@ -165,4 +165,74 @@ describe("DataTableBatchSelectionToolbar", () => {
165165 screen . getByRole ( "checkbox" , { name : "Select all rows" } ) ,
166166 ) . toHaveFocus ( ) ;
167167 } ) ;
168+
169+ it ( "applies inert to batch actions when no rows are selected" , ( ) => {
170+ const { container } = render ( DataTableBatchSelectionToolbar , {
171+ props : {
172+ selectedRowIds : [ ] ,
173+ } ,
174+ } ) ;
175+
176+ const batchActions = container . querySelector ( ".bx--batch-actions" ) ;
177+ expect ( batchActions ) . toHaveAttribute ( "inert" ) ;
178+ } ) ;
179+
180+ it ( "removes inert from batch actions when rows are selected" , ( ) => {
181+ const { container } = render ( DataTableBatchSelectionToolbar , {
182+ props : {
183+ selectedRowIds : [ "a" , "b" ] ,
184+ } ,
185+ } ) ;
186+
187+ const batchActions = container . querySelector ( ".bx--batch-actions" ) ;
188+ expect ( batchActions ) . not . toHaveAttribute ( "inert" ) ;
189+ } ) ;
190+
191+ it ( "applies inert to toolbar content when rows are selected" , async ( ) => {
192+ const { container } = render ( DataTableBatchSelectionToolbar , {
193+ props : {
194+ selectedRowIds : [ "a" , "b" ] ,
195+ } ,
196+ } ) ;
197+
198+ const toolbarContent = container . querySelector ( ".bx--toolbar-content" ) ;
199+ expect ( toolbarContent ) . toHaveAttribute ( "inert" ) ;
200+ } ) ;
201+
202+ it ( "removes inert from toolbar content when no rows are selected" , ( ) => {
203+ const { container } = render ( DataTableBatchSelectionToolbar , {
204+ props : {
205+ selectedRowIds : [ ] ,
206+ } ,
207+ } ) ;
208+
209+ const toolbarContent = container . querySelector ( ".bx--toolbar-content" ) ;
210+ expect ( toolbarContent ) . not . toHaveAttribute ( "inert" ) ;
211+ } ) ;
212+
213+ it ( "toggles inert attributes when selection changes" , async ( ) => {
214+ const { container, component } = render ( DataTableBatchSelectionToolbar , {
215+ props : {
216+ selectedRowIds : [ ] ,
217+ } ,
218+ } ) ;
219+
220+ const batchActions = container . querySelector ( ".bx--batch-actions" ) ;
221+ const toolbarContent = container . querySelector ( ".bx--toolbar-content" ) ;
222+
223+ expect ( batchActions ) . toHaveAttribute ( "inert" ) ;
224+ expect ( toolbarContent ) . not . toHaveAttribute ( "inert" ) ;
225+
226+ component . $set ( { selectedRowIds : [ "a" , "b" ] } ) ;
227+ await tick ( ) ;
228+
229+ expect ( batchActions ) . not . toHaveAttribute ( "inert" ) ;
230+ expect ( toolbarContent ) . toHaveAttribute ( "inert" ) ;
231+
232+ component . $set ( { selectedRowIds : [ ] } ) ;
233+ await tick ( ) ;
234+
235+ expect ( batchActions ) . toHaveAttribute ( "inert" ) ;
236+ expect ( toolbarContent ) . not . toHaveAttribute ( "inert" ) ;
237+ } ) ;
168238} ) ;
0 commit comments