Skip to content

Commit

Permalink
Merge pull request #33 from open-amdocs/react-17-upgrade
Browse files Browse the repository at this point in the history
React 17 upgrade
  • Loading branch information
ykadosh authored May 4, 2021
2 parents 2151429 + 2bc51c1 commit 038eeef
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 153 deletions.
208 changes: 84 additions & 124 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@
"@rollup/plugin-babel": "5.2.1",
"@rollup/plugin-commonjs": "16.0.0",
"@rollup/plugin-node-resolve": "10.0.0",
"@wojtekmaj/enzyme-adapter-react-17": "0.6.1",
"babel-eslint": "10.1.0",
"babel-loader": "8.2.2",
"babel-plugin-module-resolver": "4.0.0",
"babel-plugin-rewire": "1.2.0",
"chai": "4.2.0",
"enzyme": "3.11.0",
"enzyme-adapter-react-16": "1.15.5",
"eslint": "7.15.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-notice": "0.9.10",
Expand All @@ -59,8 +59,8 @@
"nyc": "15.1.0",
"postcss": "8.2.1",
"prop-types": "15.7.2",
"react": "16.14.0",
"react-dom": "16.14.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"rollup": "2.35.0",
"rollup-plugin-postcss": "4.0.0",
"rollup-plugin-terser": "7.0.2",
Expand Down
4 changes: 2 additions & 2 deletions src/components/Movable/Movable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ describe('<Movable/>', () => {
expect(onMove.callCount).to.eql(2);
expect(onMove.calledWith({top: 10, left: 10})).to.eql(true);

wrapper.unmount();
act(() => {wrapper.unmount()});
});

it('trackpad()', () => {
Expand Down Expand Up @@ -152,7 +152,7 @@ describe('<Movable/>', () => {
expect(onMove.callCount).to.eql(3);
expect(onMove.calledWith({top: 20, left: 20})).to.eql(true);

wrapper.unmount();
act(() => {wrapper.unmount()});
});
});
});
Expand Down
3 changes: 2 additions & 1 deletion src/components/Scrollable/Scrollable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export default class Scrollable extends React.PureComponent {
return {
className: classNames('scrollbar-inner', element.props.className),
ref: copyComponentRef(element.ref, this.container),
onScroll: this.handleOnScroll,
}
};

Expand All @@ -115,7 +116,7 @@ export default class Scrollable extends React.PureComponent {
const content = React.Children.toArray(children).filter(child => ![VerticalScrollbarPlaceholder, HorizontalScrollbarPlaceholder].includes(child.type));
return (
<ResizeObserver onResize={this.updateScrollbars}>
<div className='scrollbar' style={style} onScroll={this.handleOnScroll}>
<div className='scrollbar' style={style}>
{React.cloneElement(element, this.getElementProps(), content)}
{React.cloneElement(vsb ? vsb.props.children : <VerticalScrollbar/>, {ref: this.vertical, container: this.container})}
{React.cloneElement(hsb ? hsb.props.children : <HorizontalScrollbar/>, {ref: this.horizontal, container: this.container})}
Expand Down
25 changes: 14 additions & 11 deletions src/hooks/useClickOutside/useClickOutside.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,34 @@ import {mount, shallow} from 'enzyme';
import OverrideContext from './useClickOutside.context';
import {useClickOutside, ClickOutside, ClickOutsideOverride} from './useClickOutside';

const Elem = () => {
let test = 1234;
const ref = sinon.spy();
useClickOutside(ref, () => test = 4321);
return <div>{test}</div>;
const Elem = callback => {
useClickOutside(callback);
return <div/>;
};

describe('useClickOutside()', () => {
it('Should add an event listener to the document', () => {
document.addEventListener = sinon.spy();
document.removeEventListener = sinon.spy();

let elem;
act(() => {
elem = mount(<Elem/>);
});
expect(elem.text()).to.eql('1234');
act(() => {elem = mount(<Elem/>)});
expect(document.addEventListener.calledTwice).to.eql(true);
expect(document.addEventListener.calledWith('mousedown')).to.eql(true);
expect(document.addEventListener.calledWith('mouseup')).to.eql(true);
elem.unmount();
act(() => {elem.unmount()});
expect(document.removeEventListener.calledTwice).to.eql(true);
expect(document.removeEventListener.calledWith('mousedown')).to.eql(true);
expect(document.removeEventListener.calledWith('mouseup')).to.eql(true);
});

it('Should not trigger the callback on click inside', () => {
const callback = sinon.spy();
const elem = mount(<Elem callback={callback}/>);
expect(elem.find('div'));
elem.simulate('click');
expect(callback.callCount).to.eql(0);
});

it('<ClickOutside/>', () => {
const wrapper = shallow(<ClickOutside><div/></ClickOutside>);
expect(() => shallow(<ClickOutside/>)).to.throw();
Expand Down
Loading

0 comments on commit 038eeef

Please sign in to comment.