Skip to content

Commit

Permalink
Merge pull request #516 from redbmk/zoom-minus-button-mouseout
Browse files Browse the repository at this point in the history
ZoomControl minus button stays hovered on mouseout
  • Loading branch information
alex3165 authored Feb 4, 2018
2 parents b0bc490 + e9b483a commit 5146624
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
50 changes: 50 additions & 0 deletions src/__tests__/zoom-control.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,54 @@ describe('ZoomControl', () => {
const wrapper = shallow(<ZoomControl />);
expect(wrapper).toBeDefined();
});

describe('hovering over buttons', () => {
it('should highlight buttons on mouseover', () => {
const wrapper = shallow(<ZoomControl />);
const plus = () => wrapper.childAt(0);
const minus = () => wrapper.childAt(1);

expect(plus().props().style.opacity).toBe(0.95);
expect(minus().props().style.opacity).toBe(0.95);

plus().simulate('mouseover');
expect(plus().props().style.opacity).toBe(1);
expect(minus().props().style.opacity).toBe(0.95);

minus().simulate('mouseover');
expect(plus().props().style.opacity).toBe(0.95);
expect(minus().props().style.opacity).toBe(1);

plus().simulate('mouseover');
expect(plus().props().style.opacity).toBe(1);
expect(minus().props().style.opacity).toBe(0.95);
});

it('should remove highlight from plus button on mouseout', () => {
const wrapper = shallow(<ZoomControl />);
const plus = () => wrapper.childAt(0);
const minus = () => wrapper.childAt(1);

expect(plus().props().style.opacity).toBe(0.95);

plus().simulate('mouseover');
expect(plus().props().style.opacity).toBe(1);

minus().simulate('mouseout');
expect(plus().props().style.opacity).toBe(0.95);
});

it('should remove highlight from minus button on mouseout', () => {
const wrapper = shallow(<ZoomControl />);
const minus = () => wrapper.childAt(1);

expect(minus().props().style.opacity).toBe(0.95);

minus().simulate('mouseover');
expect(minus().props().style.opacity).toBe(1);

minus().simulate('mouseout');
expect(minus().props().style.opacity).toBe(0.95);
});
});
});
4 changes: 1 addition & 3 deletions src/zoom-control.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ export default class ZoomControl extends React.Component<Props, State> {
};

private onMouseOut = () => {
if (!this.state.hover) {
this.setState({ hover: undefined });
}
this.setState({ hover: undefined });
};

private plusOver = () => {
Expand Down

0 comments on commit 5146624

Please sign in to comment.