2016-03-25 20:03:49 +00:00
|
|
|
const assert = require('assert')
|
2017-11-14 01:21:57 +00:00
|
|
|
const {deprecations, deprecate, ipcRenderer} = require('electron')
|
2016-02-16 23:09:35 +00:00
|
|
|
|
2017-11-14 01:21:57 +00:00
|
|
|
describe.only('deprecations', () => {
|
2017-10-27 00:35:33 +00:00
|
|
|
beforeEach(() => {
|
2016-03-25 20:03:49 +00:00
|
|
|
deprecations.setHandler(null)
|
|
|
|
process.throwDeprecation = true
|
|
|
|
})
|
2016-02-16 23:09:35 +00:00
|
|
|
|
2017-11-14 18:33:38 +00:00
|
|
|
// it('allows a deprecation handler function to be specified', () => {
|
|
|
|
// const messages = []
|
|
|
|
//
|
|
|
|
// deprecations.setHandler((message) => {
|
|
|
|
// messages.push(message)
|
|
|
|
// })
|
|
|
|
//
|
|
|
|
// deprecate.log('this is deprecated')
|
|
|
|
// assert.deepEqual(messages, ['this is deprecated'])
|
|
|
|
// })
|
|
|
|
//
|
|
|
|
// it('returns a deprecation handler after one is set', () => {
|
|
|
|
// const messages = []
|
|
|
|
//
|
|
|
|
// deprecations.setHandler((message) => {
|
|
|
|
// messages.push(message)
|
|
|
|
// })
|
|
|
|
//
|
|
|
|
// deprecate.log('this is deprecated')
|
|
|
|
// assert(typeof deprecations.getHandler() === 'function')
|
|
|
|
// })
|
|
|
|
//
|
|
|
|
// it('returns a deprecation warning', () => {
|
|
|
|
// const messages = []
|
|
|
|
//
|
|
|
|
// deprecations.setHandler((message) => {
|
|
|
|
// messages.push(message)
|
|
|
|
// })
|
|
|
|
//
|
|
|
|
// deprecate.warn('old', 'new')
|
|
|
|
// assert.deepEqual(messages, [`'old' is deprecated. Use 'new' instead.`])
|
|
|
|
// })
|
2017-11-14 01:21:57 +00:00
|
|
|
|
2017-11-14 18:33:38 +00:00
|
|
|
// it('throws an exception if no deprecation handler is specified', () => {
|
|
|
|
// assert.throws(() => {
|
|
|
|
// deprecate.log('this is deprecated')
|
|
|
|
// }, /this is deprecated/)
|
|
|
|
// })
|
2017-11-14 01:21:57 +00:00
|
|
|
|
|
|
|
// it('deprecates a property', () => {
|
|
|
|
// deprecate.property(object, property, method)
|
|
|
|
// })
|
|
|
|
//
|
|
|
|
// it('deprecates an event', () => {
|
|
|
|
// deprecate.event(emitter, oldName, newName, fn)
|
|
|
|
// })
|
|
|
|
//
|
|
|
|
// it('forwards a method to member', () => {
|
|
|
|
// deprecate.member(object, method, member)
|
|
|
|
// })
|
|
|
|
|
|
|
|
it('renames a method', () => {
|
|
|
|
assert(typeof ipcRenderer.sendSync === 'function')
|
2017-11-14 18:33:38 +00:00
|
|
|
assert(typeof ipcRenderer.sendChannelSync === 'undefined')
|
2017-11-14 01:21:57 +00:00
|
|
|
deprecate.rename(ipcRenderer, 'sendSync', 'sendChannelSync')
|
2017-11-14 18:33:38 +00:00
|
|
|
assert(typeof ipcRenderer.sendChannelSync === 'function')
|
2017-11-14 01:21:57 +00:00
|
|
|
})
|
2016-03-25 20:03:49 +00:00
|
|
|
})
|