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