first pass at deprecation spec updates

This commit is contained in:
Shelley Vohr 2017-11-13 20:21:57 -05:00
parent 4d364fa27a
commit d05a1f8053
No known key found for this signature in database
GPG key ID: F13993A75599653C
2 changed files with 62 additions and 29 deletions

View file

@ -1,7 +1,7 @@
const assert = require('assert')
const {deprecations, deprecate} = require('electron')
const {deprecations, deprecate, ipcRenderer} = require('electron')
describe('deprecations', () => {
describe.only('deprecations', () => {
beforeEach(() => {
deprecations.setHandler(null)
process.throwDeprecation = true
@ -18,9 +18,50 @@ describe('deprecations', () => {
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.`])
})
it('throws an exception if no deprecation handler is specified', () => {
assert.throws(() => {
deprecate.log('this is deprecated')
}, /this is deprecated/)
})
// 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')
deprecate.rename(ipcRenderer, 'sendSync', 'sendChannelSync')
assert(typeof ipcRenderer.sendSync === 'undefined')
// assert(typeof ipcRenderer.sendChannelSync === 'function')
})
})