-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Overlay): add ref support (#5710)
- Loading branch information
Showing
3 changed files
with
113 additions
and
68 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
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import * as React from 'react'; | ||
import { mount } from 'enzyme'; | ||
|
||
import Overlay from '../src/Overlay'; | ||
import Popover from '../src/Popover'; | ||
|
||
describe('<Overlay>', () => { | ||
it('should forward ref to the overlay', () => { | ||
const ref = React.createRef(); | ||
mount( | ||
<Overlay ref={ref} show> | ||
<Popover id="my-overlay">test</Popover> | ||
</Overlay>, | ||
); | ||
|
||
ref.current.id.should.equal('my-overlay'); | ||
}); | ||
|
||
it('should use Fade internally if transition=true', () => { | ||
const wrapper = mount( | ||
<Overlay show transition> | ||
<Popover id="my-overlay">test</Popover> | ||
</Overlay>, | ||
); | ||
|
||
expect(wrapper.find('Fade').exists()).to.be.true; | ||
}); | ||
|
||
it('should not use Fade if transition=false', () => { | ||
const wrapper = mount( | ||
<Overlay show transition={false}> | ||
<Popover id="my-overlay">test</Popover> | ||
</Overlay>, | ||
); | ||
|
||
expect(wrapper.find('Fade').exists()).to.be.false; | ||
}); | ||
}); |