2016-03-25 20:03:49 +00:00
|
|
|
const assert = require('assert')
|
2017-10-27 00:35:33 +00:00
|
|
|
const {deprecations, deprecate} = require('electron')
|
2016-02-16 23:09:35 +00:00
|
|
|
|
2017-10-27 00:35:33 +00:00
|
|
|
describe('deprecations', () => {
|
|
|
|
beforeEach(() => {
|
2016-03-25 20:03:49 +00:00
|
|
|
deprecations.setHandler(null)
|
|
|
|
process.throwDeprecation = true
|
|
|
|
})
|
2016-02-16 23:09:35 +00:00
|
|
|
|
2017-10-27 00:35:33 +00:00
|
|
|
it('allows a deprecation handler function to be specified', () => {
|
|
|
|
const messages = []
|
2016-02-16 23:09:35 +00:00
|
|
|
|
2017-10-27 00:35:33 +00:00
|
|
|
deprecations.setHandler((message) => {
|
2016-03-25 20:03:49 +00:00
|
|
|
messages.push(message)
|
|
|
|
})
|
2016-02-16 23:09:35 +00:00
|
|
|
|
2017-10-27 00:35:33 +00:00
|
|
|
deprecate.log('this is deprecated')
|
2016-04-28 18:15:39 +00:00
|
|
|
assert.deepEqual(messages, ['this is deprecated'])
|
2016-03-25 20:03:49 +00:00
|
|
|
})
|
2016-02-16 23:09:35 +00:00
|
|
|
|
2017-10-27 00:35:33 +00:00
|
|
|
it('throws an exception if no deprecation handler is specified', () => {
|
|
|
|
assert.throws(() => {
|
|
|
|
deprecate.log('this is deprecated')
|
2016-04-28 18:17:03 +00:00
|
|
|
}, /this is deprecated/)
|
2016-03-25 20:03:49 +00:00
|
|
|
})
|
|
|
|
})
|