forked from airbnb/visx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request airbnb#666 from dennisja/remove-default-styles
Remove tooltip default styles
- Loading branch information
Showing
5 changed files
with
55 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export { default as withTooltip } from './enhancers/withTooltip'; | ||
export { default as useTooltip } from './hooks/useTooltip'; | ||
export { default as Tooltip } from './tooltips/Tooltip'; | ||
export { default as Tooltip, defaultStyles } from './tooltips/Tooltip'; | ||
export { default as TooltipWithBounds } from './tooltips/TooltipWithBounds'; |
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 |
---|---|---|
@@ -1,7 +1,43 @@ | ||
import { Tooltip } from '../src'; | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { Tooltip, defaultStyles } from '../src'; | ||
|
||
describe('<Tooltip />', () => { | ||
test('it should be defined', () => { | ||
expect(Tooltip).toBeDefined(); | ||
}); | ||
|
||
it('should render with the default styles', () => { | ||
const wrapper = shallow(<Tooltip>Hello</Tooltip>); | ||
const styles = wrapper.props().style; | ||
Object.entries(defaultStyles).forEach(([key, value]) => { | ||
expect(styles[key]).toBe(value); | ||
}); | ||
}); | ||
|
||
it('should render with no default styles', () => { | ||
const wrapper = shallow(<Tooltip unstyled>Hello</Tooltip>); | ||
const styles = wrapper.props().style; | ||
Object.keys(defaultStyles).forEach(key => { | ||
expect(styles[key]).toBe(undefined); | ||
}); | ||
}); | ||
|
||
it('should overwrite default styles when given the style prop', () => { | ||
const newStyles: React.CSSProperties = { | ||
position: 'relative', | ||
backgroundColor: 'green', | ||
color: 'red', | ||
padding: '.8rem .8rem', | ||
borderRadius: '13px', | ||
fontSize: '17px', | ||
boxShadow: '0 2px 3px rgba(133,133,133,0.5)', | ||
lineHeight: '2em', | ||
}; | ||
const wrapper = shallow(<Tooltip style={newStyles}></Tooltip>); | ||
const styles = wrapper.props().style; | ||
Object.entries(newStyles).forEach(([key, value]) => { | ||
expect(styles[key]).toBe(value); | ||
}); | ||
}); | ||
}); |