Skip to content

Commit

Permalink
fix: React deprecation warnings (jquense#970)
Browse files Browse the repository at this point in the history
* upgrades uncontrollable to ^7.1.0
* fixes uncontrollable imports
* fixes DateTimePicker test cases
  • Loading branch information
rypadilla committed Dec 6, 2019
1 parent 1dfe620 commit c38cfbb
Show file tree
Hide file tree
Showing 11 changed files with 597 additions and 61 deletions.
2 changes: 1 addition & 1 deletion packages/react-widgets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"react-component-managers": "^3.1.0",
"react-lifecycles-compat": "^3.0.4",
"react-transition-group": "^2.4.0",
"uncontrollable": "^5.0.0",
"uncontrollable": "^7.1.1",
"warning": "^3.0.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-widgets/src/Autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import cn from 'classnames'
import * as PropTypes from 'prop-types'
import React from 'react'
import { polyfill as polyfillLifecycles } from 'react-lifecycles-compat'
import uncontrollable from 'uncontrollable'
import { uncontrollable } from 'uncontrollable'

import List from './List'
import Popup from './Popup'
Expand Down
2 changes: 1 addition & 1 deletion packages/react-widgets/src/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import { findDOMNode } from 'react-dom'
import PropTypes from 'prop-types'
import cn from 'classnames'
import uncontrollable from 'uncontrollable'
import { uncontrollable } from 'uncontrollable'
import { polyfill as polyfillLifecycles } from 'react-lifecycles-compat'
import { autoFocus } from 'react-component-managers'

Expand Down
2 changes: 1 addition & 1 deletion packages/react-widgets/src/Combobox.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import PropTypes from 'prop-types'
import cn from 'classnames'
import { polyfill as polyfillLifecycles } from 'react-lifecycles-compat'
import createUncontrolledWidget from 'uncontrollable'
import { uncontrollable as createUncontrolledWidget } from 'uncontrollable'

import Widget from './Widget'
import WidgetPicker from './WidgetPicker'
Expand Down
2 changes: 1 addition & 1 deletion packages/react-widgets/src/DateTimePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { polyfill as polyfillLifecycles } from 'react-lifecycles-compat'
import activeElement from 'dom-helpers/activeElement'
import cn from 'classnames'
import deprecated from 'prop-types-extra/lib/deprecated'
import uncontrollable from 'uncontrollable'
import { uncontrollable } from 'uncontrollable'

import Widget from './Widget'
import WidgetPicker from './WidgetPicker'
Expand Down
2 changes: 1 addition & 1 deletion packages/react-widgets/src/DropdownList.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
timeoutManager,
} from 'react-component-managers'
import { polyfill as polyfillLifecycles } from 'react-lifecycles-compat'
import uncontrollable from 'uncontrollable'
import { uncontrollable } from 'uncontrollable'

import Widget from './Widget'
import WidgetPicker from './WidgetPicker'
Expand Down
2 changes: 1 addition & 1 deletion packages/react-widgets/src/Multiselect.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import closest from 'dom-helpers/query/closest'
import PropTypes from 'prop-types'
import React from 'react'
import { polyfill as polyfillLifecycles } from 'react-lifecycles-compat'
import uncontrollable from 'uncontrollable'
import { uncontrollable } from 'uncontrollable'

import Widget from './Widget'
import WidgetPicker from './WidgetPicker'
Expand Down
2 changes: 1 addition & 1 deletion packages/react-widgets/src/NumberPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import cn from 'classnames'
import PropTypes from 'prop-types'
import React from 'react'
import { polyfill as polyfillLifecycles } from 'react-lifecycles-compat'
import uncontrollable from 'uncontrollable'
import { uncontrollable } from 'uncontrollable'

import Widget from './Widget'
import WidgetPicker from './WidgetPicker'
Expand Down
2 changes: 1 addition & 1 deletion packages/react-widgets/src/SelectList.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { polyfill as polyfillLifecycles } from 'react-lifecycles-compat'
import PropTypes from 'prop-types'
import cn from 'classnames'
import { autoFocus, timeoutManager } from 'react-component-managers'
import createUncontrolledWidget from 'uncontrollable'
import { uncontrollable as createUncontrolledWidget } from 'uncontrollable'

import List from './List'
import Widget from './Widget'
Expand Down
18 changes: 11 additions & 7 deletions packages/react-widgets/test/DateTimePicker-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ describe('DateTimePicker', () => {
})

it('should do nothing when disabled', done => {
let wrapper = mount(<DateTimePicker defaultValue={new Date()} disabled />)
let instanceRef = React.createRef()
let wrapper = mount(<DateTimePicker defaultValue={new Date()} disabled ref={instanceRef} />)

let input = wrapper.find('.rw-input').getDOMNode()

Expand All @@ -201,13 +202,14 @@ describe('DateTimePicker', () => {
wrapper.find('.rw-i-calendar').simulate('click')

setTimeout(() => {
expect(wrapper.instance()._values.open).to.not.equal(true)
expect(instanceRef.current.props.open).to.not.equal(true)
done()
}, 0)
})

it('should do nothing when readonly', done => {
let wrapper = mount(<DateTimePicker defaultValue={new Date()} readOnly />)
let instanceRef = React.createRef()
let wrapper = mount(<DateTimePicker defaultValue={new Date()} readOnly ref={instanceRef} />)

let input = wrapper.find('.rw-input').getDOMNode()

Expand All @@ -217,25 +219,27 @@ describe('DateTimePicker', () => {
wrapper.find('.rw-i-calendar').simulate('click')

setTimeout(() => {
expect(wrapper.instance()._values.open).to.not.equal(true)
expect(instanceRef.current.props.open).to.not.equal(true)
done()
})
})

it('should change values on key down', () => {
let instanceRef = React.createRef()

let change = sinon.spy()

let wrapper = mount(<DateTimePicker onChange={change} />)
let wrapper = mount(<DateTimePicker onChange={change} ref={instanceRef} />)

let options = wrapper.find('li').map(n => n.getDOMNode())

wrapper.simulate('keyDown', { key: 'ArrowDown', altKey: true })

expect(wrapper.instance()._values.open).to.equal('date')
expect(instanceRef.current.props.open).to.equal('date')

wrapper.simulate('keyDown', { key: 'ArrowDown', altKey: true })

expect(wrapper.instance()._values.open).to.equal('time')
expect(instanceRef.current.props.open).to.equal('time')

wrapper.simulate('keyDown', { key: 'Home' })

Expand Down
Loading

0 comments on commit c38cfbb

Please sign in to comment.