Skip to content

Commit bccc0dd

Browse files
committed
to.be.focused -> to.have.focus
1 parent c7a8509 commit bccc0dd

File tree

13 files changed

+134
-133
lines changed

13 files changed

+134
-133
lines changed

packages/material-ui-lab/src/Autocomplete/Autocomplete.test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ describe('<Autocomplete />', () => {
246246

247247
const textbox = getByRole('textbox');
248248
const options = getAllByRole('option');
249-
expect(textbox).to.be.focused;
249+
expect(textbox).to.have.focus;
250250
expect(textbox).to.have.attribute(
251251
'aria-activedescendant',
252252
options[options.length - 1].getAttribute('id'),
@@ -266,7 +266,7 @@ describe('<Autocomplete />', () => {
266266

267267
const options = getAllByRole('option');
268268
const textbox = getByRole('textbox');
269-
expect(textbox).to.be.focused;
269+
expect(textbox).to.have.focus;
270270
expect(textbox).to.have.attribute('aria-activedescendant', options[0].getAttribute('id'));
271271
});
272272

@@ -284,7 +284,7 @@ describe('<Autocomplete />', () => {
284284
fireEvent.keyDown(document.activeElement, { key: 'ArrowUp' });
285285

286286
const textbox = getByRole('textbox');
287-
expect(textbox).to.be.focused;
287+
expect(textbox).to.have.focus;
288288
expect(textbox).not.to.have.attribute('aria-activedescendant');
289289
});
290290

@@ -301,7 +301,7 @@ describe('<Autocomplete />', () => {
301301
fireEvent.keyDown(document.activeElement, { key: 'ArrowDown' });
302302

303303
const textbox = getByRole('textbox');
304-
expect(textbox).to.be.focused;
304+
expect(textbox).to.have.focus;
305305
expect(textbox).not.to.have.attribute('aria-activedescendant');
306306
});
307307
});
@@ -320,7 +320,7 @@ describe('<Autocomplete />', () => {
320320
fireEvent.keyDown(document.activeElement, { key: 'ArrowUp' });
321321

322322
const textbox = getByRole('textbox');
323-
expect(textbox).to.be.focused;
323+
expect(textbox).to.have.focus;
324324
expect(textbox).to.have.attribute(
325325
'aria-activedescendant',
326326
getAllByRole('option')[0].getAttribute('id'),
@@ -340,7 +340,7 @@ describe('<Autocomplete />', () => {
340340

341341
const textbox = getByRole('textbox');
342342
const options = getAllByRole('option');
343-
expect(textbox).to.be.focused;
343+
expect(textbox).to.have.focus;
344344
expect(textbox).to.have.attribute(
345345
'aria-activedescendant',
346346
options[options.length - 1].getAttribute('id'),
@@ -362,7 +362,7 @@ describe('<Autocomplete />', () => {
362362

363363
const textbox = getByRole('textbox');
364364
const options = getAllByRole('option');
365-
expect(textbox).to.be.focused;
365+
expect(textbox).to.have.focus;
366366
expect(textbox).to.have.attribute(
367367
'aria-activedescendant',
368368
options[options.length - 1].getAttribute('id'),

packages/material-ui-lab/src/TreeItem/TreeItem.test.js

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,12 @@ describe('<TreeItem />', () => {
207207
);
208208

209209
getByTestId('start').focus();
210-
expect(getByTestId('start')).to.be.focused;
210+
expect(getByTestId('start')).to.have.focus;
211211

212212
fireEvent.keyDown(document.activeElement, { key: 'Tab' });
213213
getByTestId('one').focus();
214214

215-
expect(getByTestId('one')).to.be.focused;
215+
expect(getByTestId('one')).to.have.focus;
216216
});
217217

218218
it('should focus the selected node if a node is selected before the tree receives focus', () => {
@@ -229,15 +229,15 @@ describe('<TreeItem />', () => {
229229
);
230230

231231
fireEvent.click(getByText('two'));
232-
expect(getByTestId('two')).to.be.focused;
232+
expect(getByTestId('two')).to.have.focus;
233233

234234
getByTestId('start').focus();
235-
expect(getByTestId('start')).to.be.focused;
235+
expect(getByTestId('start')).to.have.focus;
236236

237237
fireEvent.keyDown(document.activeElement, { key: 'Tab' });
238238
getByTestId('two').focus();
239239

240-
expect(getByTestId('two')).to.be.focused;
240+
expect(getByTestId('two')).to.have.focus;
241241
});
242242
});
243243

@@ -255,7 +255,7 @@ describe('<TreeItem />', () => {
255255
getByTestId('one').focus();
256256
fireEvent.keyDown(document.activeElement, { key: 'ArrowRight' });
257257
expect(getByTestId('one')).to.have.attribute('aria-expanded', 'true');
258-
expect(getByTestId('one')).to.be.focused;
258+
expect(getByTestId('one')).to.have.focus;
259259
});
260260

261261
it('should move focus to the first child if focus is on an open node', () => {
@@ -270,7 +270,7 @@ describe('<TreeItem />', () => {
270270
expect(getByTestId('one')).to.have.attribute('aria-expanded', 'true');
271271
getByTestId('one').focus();
272272
fireEvent.keyDown(document.activeElement, { key: 'ArrowRight' });
273-
expect(getByTestId('two')).to.be.focused;
273+
expect(getByTestId('two')).to.have.focus;
274274
});
275275

276276
it('should do nothing if focus is on an end node', () => {
@@ -283,9 +283,9 @@ describe('<TreeItem />', () => {
283283
);
284284

285285
fireEvent.click(getByText('two'));
286-
expect(getByTestId('two')).to.be.focused;
286+
expect(getByTestId('two')).to.have.focus;
287287
fireEvent.keyDown(document.activeElement, { key: 'ArrowRight' });
288-
expect(getByTestId('two')).to.be.focused;
288+
expect(getByTestId('two')).to.have.focus;
289289
});
290290
});
291291

@@ -304,7 +304,7 @@ describe('<TreeItem />', () => {
304304
getByTestId('one').focus();
305305
fireEvent.keyDown(document.activeElement, { key: 'ArrowLeft' });
306306
expect(getByTestId('one')).to.have.attribute('aria-expanded', 'false');
307-
expect(getByTestId('one')).to.be.focused;
307+
expect(getByTestId('one')).to.have.focus;
308308
});
309309

310310
it("should move focus to the node's parent node if focus is on a child node that is an end node", () => {
@@ -319,7 +319,7 @@ describe('<TreeItem />', () => {
319319
expect(getByTestId('one')).to.have.attribute('aria-expanded', 'true');
320320
fireEvent.click(getByText('two'));
321321
fireEvent.keyDown(document.activeElement, { key: 'ArrowLeft' });
322-
expect(getByTestId('one')).to.be.focused;
322+
expect(getByTestId('one')).to.have.focus;
323323
expect(getByTestId('one')).to.have.attribute('aria-expanded', 'true');
324324
});
325325

@@ -341,7 +341,7 @@ describe('<TreeItem />', () => {
341341
fireEvent.click(getByText('two'));
342342
expect(getByTestId('two')).to.have.attribute('aria-expanded', 'false');
343343
fireEvent.keyDown(document.activeElement, { key: 'ArrowLeft' });
344-
expect(getByTestId('one')).to.be.focused;
344+
expect(getByTestId('one')).to.have.focus;
345345
expect(getByTestId('one')).to.have.attribute('aria-expanded', 'true');
346346
});
347347

@@ -357,7 +357,7 @@ describe('<TreeItem />', () => {
357357
getByTestId('one').focus();
358358
expect(getByTestId('one')).to.have.attribute('aria-expanded', 'false');
359359
fireEvent.keyDown(document.activeElement, { key: 'ArrowLeft' });
360-
expect(getByTestId('one')).to.be.focused;
360+
expect(getByTestId('one')).to.have.focus;
361361
});
362362

363363
it('should do nothing if focus is on a root node that is an end node', () => {
@@ -369,7 +369,7 @@ describe('<TreeItem />', () => {
369369

370370
getByTestId('one').focus();
371371
fireEvent.keyDown(document.activeElement, { key: 'ArrowLeft' });
372-
expect(getByTestId('one')).to.be.focused;
372+
expect(getByTestId('one')).to.have.focus;
373373
});
374374
});
375375

@@ -384,7 +384,7 @@ describe('<TreeItem />', () => {
384384

385385
getByTestId('one').focus();
386386
fireEvent.keyDown(document.activeElement, { key: 'ArrowDown' });
387-
expect(getByTestId('two')).to.be.focused;
387+
expect(getByTestId('two')).to.have.focus;
388388
});
389389

390390
it('moves focus to a nested node', () => {
@@ -399,7 +399,7 @@ describe('<TreeItem />', () => {
399399
expect(getByTestId('one')).to.have.attribute('aria-expanded', 'true');
400400
getByTestId('one').focus();
401401
fireEvent.keyDown(document.activeElement, { key: 'ArrowDown' });
402-
expect(getByTestId('two')).to.be.focused;
402+
expect(getByTestId('two')).to.have.focus;
403403
});
404404

405405
it("moves focus to a parent's sibling", () => {
@@ -414,9 +414,9 @@ describe('<TreeItem />', () => {
414414

415415
expect(getByTestId('one')).to.have.attribute('aria-expanded', 'true');
416416
fireEvent.click(getByText('two'));
417-
expect(getByTestId('two')).to.be.focused;
417+
expect(getByTestId('two')).to.have.focus;
418418
fireEvent.keyDown(document.activeElement, { key: 'ArrowDown' });
419-
expect(getByTestId('three')).to.be.focused;
419+
expect(getByTestId('three')).to.have.focus;
420420
});
421421
});
422422

@@ -430,9 +430,9 @@ describe('<TreeItem />', () => {
430430
);
431431

432432
fireEvent.click(getByText('two'));
433-
expect(getByTestId('two')).to.be.focused;
433+
expect(getByTestId('two')).to.have.focus;
434434
fireEvent.keyDown(document.activeElement, { key: 'ArrowUp' });
435-
expect(getByTestId('one')).to.be.focused;
435+
expect(getByTestId('one')).to.have.focus;
436436
});
437437

438438
it('moves focus to a parent', () => {
@@ -446,9 +446,9 @@ describe('<TreeItem />', () => {
446446

447447
expect(getByTestId('one')).to.have.attribute('aria-expanded', 'true');
448448
fireEvent.click(getByText('two'));
449-
expect(getByTestId('two')).to.be.focused;
449+
expect(getByTestId('two')).to.have.focus;
450450
fireEvent.keyDown(document.activeElement, { key: 'ArrowUp' });
451-
expect(getByTestId('one')).to.be.focused;
451+
expect(getByTestId('one')).to.have.focus;
452452
});
453453

454454
it("moves focus to a sibling's child", () => {
@@ -463,9 +463,9 @@ describe('<TreeItem />', () => {
463463

464464
expect(getByTestId('one')).to.have.attribute('aria-expanded', 'true');
465465
fireEvent.click(getByText('three'));
466-
expect(getByTestId('three')).to.be.focused;
466+
expect(getByTestId('three')).to.have.focus;
467467
fireEvent.keyDown(document.activeElement, { key: 'ArrowUp' });
468-
expect(getByTestId('two')).to.be.focused;
468+
expect(getByTestId('two')).to.have.focus;
469469
});
470470
});
471471

@@ -481,9 +481,9 @@ describe('<TreeItem />', () => {
481481
);
482482

483483
fireEvent.click(getByText('four'));
484-
expect(getByTestId('four')).to.be.focused;
484+
expect(getByTestId('four')).to.have.focus;
485485
fireEvent.keyDown(document.activeElement, { key: 'Home' });
486-
expect(getByTestId('one')).to.be.focused;
486+
expect(getByTestId('one')).to.have.focus;
487487
});
488488
});
489489

@@ -499,9 +499,9 @@ describe('<TreeItem />', () => {
499499
);
500500

501501
getByTestId('one').focus();
502-
expect(getByTestId('one')).to.be.focused;
502+
expect(getByTestId('one')).to.have.focus;
503503
fireEvent.keyDown(document.activeElement, { key: 'End' });
504-
expect(getByTestId('four')).to.be.focused;
504+
expect(getByTestId('four')).to.have.focus;
505505
});
506506

507507
it('moves focus to the last node in the tree with expanded items', () => {
@@ -519,9 +519,9 @@ describe('<TreeItem />', () => {
519519
);
520520

521521
getByTestId('one').focus();
522-
expect(getByTestId('one')).to.be.focused;
522+
expect(getByTestId('one')).to.have.focus;
523523
fireEvent.keyDown(document.activeElement, { key: 'End' });
524-
expect(getByTestId('six')).to.be.focused;
524+
expect(getByTestId('six')).to.have.focus;
525525
});
526526
});
527527

@@ -569,15 +569,15 @@ describe('<TreeItem />', () => {
569569
);
570570

571571
getByTestId('one').focus();
572-
expect(getByTestId('one')).to.be.focused;
572+
expect(getByTestId('one')).to.have.focus;
573573
fireEvent.keyDown(document.activeElement, { key: 't' });
574-
expect(getByTestId('two')).to.be.focused;
574+
expect(getByTestId('two')).to.have.focus;
575575

576576
fireEvent.keyDown(document.activeElement, { key: 'f' });
577-
expect(getByTestId('four')).to.be.focused;
577+
expect(getByTestId('four')).to.have.focus;
578578

579579
fireEvent.keyDown(document.activeElement, { key: 'o' });
580-
expect(getByTestId('one')).to.be.focused;
580+
expect(getByTestId('one')).to.have.focus;
581581
});
582582

583583
it('moves focus to the next node with the same starting character', () => {
@@ -591,15 +591,15 @@ describe('<TreeItem />', () => {
591591
);
592592

593593
getByTestId('one').focus();
594-
expect(getByTestId('one')).to.be.focused;
594+
expect(getByTestId('one')).to.have.focus;
595595
fireEvent.keyDown(document.activeElement, { key: 't' });
596-
expect(getByTestId('two')).to.be.focused;
596+
expect(getByTestId('two')).to.have.focus;
597597

598598
fireEvent.keyDown(document.activeElement, { key: 't' });
599-
expect(getByTestId('three')).to.be.focused;
599+
expect(getByTestId('three')).to.have.focus;
600600

601601
fireEvent.keyDown(document.activeElement, { key: 't' });
602-
expect(getByTestId('two')).to.be.focused;
602+
expect(getByTestId('two')).to.have.focus;
603603
});
604604
});
605605

packages/material-ui-lab/src/TreeView/TreeView.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ describe('<TreeView />', () => {
5050
const { getByText, getByTestId } = render(<MyComponent />);
5151

5252
fireEvent.click(getByText('one'));
53-
expect(getByTestId('one')).to.be.focused;
53+
expect(getByTestId('one')).to.have.focus;
5454
fireEvent.keyDown(document.activeElement, { key: 'ArrowDown' });
55-
expect(getByTestId('two')).to.be.focused;
55+
expect(getByTestId('two')).to.have.focus;
5656
fireEvent.keyDown(document.activeElement, { key: 'ArrowUp' });
57-
expect(getByTestId('one')).to.be.focused;
57+
expect(getByTestId('one')).to.have.focus;
5858
fireEvent.keyDown(document.activeElement, { key: 'ArrowDown' });
59-
expect(getByTestId('two')).to.be.focused;
59+
expect(getByTestId('two')).to.have.focus;
6060
});
6161

6262
describe('onNodeToggle', () => {

packages/material-ui/src/ButtonBase/ButtonBase.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ describe('<ButtonBase />', () => {
608608
// so we need to check if we're resilient against it
609609
const { getByText } = render(<ButtonBase autoFocus>Hello</ButtonBase>);
610610

611-
expect(getByText('Hello')).to.be.focused;
611+
expect(getByText('Hello')).to.have.focus;
612612
});
613613
});
614614

@@ -753,7 +753,7 @@ describe('<ButtonBase />', () => {
753753
expect(typeof buttonActionsRef.current.focusVisible).to.equal('function');
754754
// @ts-ignore
755755
buttonActionsRef.current.focusVisible();
756-
expect(getByText('Hello')).to.be.focused;
756+
expect(getByText('Hello')).to.have.focus;
757757
expect(getByText('Hello')).to.match('.focusVisible');
758758
});
759759
});

packages/material-ui/src/ExpansionPanelSummary/ExpansionPanelSummary.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ describe('<ExpansionPanelSummary />', () => {
7777
fireEvent.keyDown(document.activeElement, { key: 'Tab' }); // not actually focusing (yet)
7878
button.focus();
7979

80-
expect(button).to.be.focused;
80+
expect(button).to.have.focus;
8181
expect(button).to.have.class(classes.focused);
8282
});
8383

@@ -90,7 +90,7 @@ describe('<ExpansionPanelSummary />', () => {
9090

9191
button.blur();
9292

93-
expect(button).not.to.be.focused;
93+
expect(button).not.to.have.focus;
9494
expect(button).not.to.have.class(classes.focused);
9595
});
9696

packages/material-ui/src/Modal/Modal.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -589,15 +589,15 @@ describe('<Modal />', () => {
589589
const { getByRole, setProps } = render(<WithRemovableElement />);
590590
const dialog = getByRole('dialog');
591591
const toggleButton = getByRole('button');
592-
expect(dialog).to.be.focused;
592+
expect(dialog).to.have.focus;
593593

594594
toggleButton.focus();
595-
expect(toggleButton).to.be.focused;
595+
expect(toggleButton).to.have.focus;
596596

597597
setProps({ hideButton: true });
598-
expect(dialog).to.not.be.focused;
598+
expect(dialog).not.to.have.focus;
599599
clock.tick(500); // wait for the interval check to kick in.
600-
expect(dialog).to.be.focused;
600+
expect(dialog).to.have.focus;
601601
});
602602
});
603603
});

0 commit comments

Comments
 (0)