chore: add deprecation helper for fnToProperty (#17377)

* chore: add deprecation helper for fnToProperty

* add a test
This commit is contained in:
Shelley Vohr 2019-03-14 15:19:19 -07:00 committed by GitHub
parent 12b6a0f5b2
commit cb4ede453f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 0 deletions

View file

@ -144,6 +144,32 @@ describe('deprecations', () => {
}).to.throw(/this is deprecated/)
})
it('warns when a function is deprecated in favor of a property', () => {
const warnings = []
deprecations.setHandler(warning => warnings.push(warning))
function oldGetterFn () { return 'getter' }
function oldSetterFn () { return 'setter' }
const newProp = 'myRadProp'
const [
deprecatedGetter,
deprecatedSetter
] = deprecate.fnToProperty(newProp, oldGetterFn, oldSetterFn)
deprecatedGetter()
deprecatedSetter()
expect(warnings).to.have.lengthOf(2)
expect(warnings[0]).to.include('oldGetterFn')
expect(warnings[0]).to.include(newProp)
expect(warnings[1]).to.include('oldSetterFn')
expect(warnings[1]).to.include(newProp)
})
describe('promisify', () => {
const expected = 'Hello, world!'
let promiseFunc