forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Breadcrumbs] Fix expand/collapsed Breadcrumbs via keyboard (mui#19724)
- Loading branch information
1 parent
63abd74
commit a336ae8
Showing
6 changed files
with
55 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 27 additions & 17 deletions
44
packages/material-ui/src/Breadcrumbs/BreadcrumbCollapsed.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,42 @@ | ||
import React from 'react'; | ||
import { assert } from 'chai'; | ||
import { createShallow, createMount, getClasses } from '@material-ui/core/test-utils'; | ||
import { expect } from 'chai'; | ||
import { spy } from 'sinon'; | ||
import { getClasses } from '@material-ui/core/test-utils'; | ||
import BreadcrumbCollapsed from './BreadcrumbCollapsed'; | ||
import MoreHorizIcon from '../internal/svg-icons/MoreHoriz'; | ||
import { fireEvent, createClientRender } from 'test/utils/createClientRender'; | ||
|
||
describe('<BreadcrumbCollapsed />', () => { | ||
let mount; | ||
let shallow; | ||
let classes; | ||
const render = createClientRender(); | ||
|
||
before(() => { | ||
shallow = createShallow({ dive: true }); | ||
mount = createMount({ strict: true }); | ||
classes = getClasses(<BreadcrumbCollapsed />); | ||
}); | ||
|
||
after(() => { | ||
mount.cleanUp(); | ||
}); | ||
|
||
it('should render an <SvgIcon>', () => { | ||
const wrapper = shallow(<BreadcrumbCollapsed />); | ||
it('should render an icon', () => { | ||
const { container } = render(<BreadcrumbCollapsed />); | ||
|
||
assert.strictEqual(wrapper.find(MoreHorizIcon).length, 1); | ||
assert.strictEqual(wrapper.hasClass(classes.root), true); | ||
expect(container.querySelectorAll('svg').length).to.equal(1); | ||
expect(container.firstChild).to.have.class(classes.root); | ||
}); | ||
|
||
it('should mount', () => { | ||
mount(<BreadcrumbCollapsed />); | ||
describe('prop: onKeyDown', () => { | ||
it(`should be called on key down - Enter`, () => { | ||
const handleClick = spy(); | ||
const { container } = render(<BreadcrumbCollapsed onClick={handleClick} />); | ||
const expand = container.firstChild; | ||
expand.focus(); | ||
fireEvent.keyDown(expand, { key: 'Enter' }); | ||
expect(handleClick.callCount).to.equal(1); | ||
}); | ||
|
||
it(`should be called on key up - Space`, () => { | ||
const handleClick = spy(); | ||
const { container } = render(<BreadcrumbCollapsed onClick={handleClick} />); | ||
const expand = container.firstChild; | ||
expand.focus(); | ||
fireEvent.keyUp(expand, { key: ' ' }); | ||
expect(handleClick.callCount).to.equal(1); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters