|
| 1 | +var _Raven = require('../../src/raven'); |
| 2 | +var consolePlugin = require('../../plugins/console'); |
| 3 | + |
| 4 | +var Raven; |
| 5 | +describe('console plugin', function () { |
| 6 | + beforeEach(function () { |
| 7 | + Raven = new _Raven(); |
| 8 | + Raven.config('http://abc@example.com:80/2'); |
| 9 | + }); |
| 10 | + |
| 11 | + it('should call Raven.captureMessage', function () { |
| 12 | + var console = { |
| 13 | + debug: function () {}, |
| 14 | + info: function () {}, |
| 15 | + warn: function () {}, |
| 16 | + error: function () {} |
| 17 | + }; |
| 18 | + |
| 19 | + consolePlugin(Raven, console); |
| 20 | + |
| 21 | + this.sinon.stub(Raven, 'captureMessage'); |
| 22 | + console.error('Raven should capture', 'console.error'); |
| 23 | + |
| 24 | + assert.equal(Raven.captureMessage.callCount, 1); |
| 25 | + assert.equal(Raven.captureMessage.getCall(0).args[0], 'Raven should capture console.error'); |
| 26 | + assert.deepEqual(Raven.captureMessage.getCall(0).args[1], { |
| 27 | + level: 'error', |
| 28 | + logger: 'console', |
| 29 | + extra: { |
| 30 | + arguments: ['Raven should capture', 'console.error'] |
| 31 | + } |
| 32 | + }); |
| 33 | + |
| 34 | + Raven.captureMessage.reset(); |
| 35 | + |
| 36 | + console.warn('Raven should capture console.warn'); |
| 37 | + |
| 38 | + assert.equal(Raven.captureMessage.callCount, 1); |
| 39 | + assert.equal(Raven.captureMessage.getCall(0).args[0], 'Raven should capture console.warn'); |
| 40 | + assert.deepEqual(Raven.captureMessage.getCall(0).args[1], { |
| 41 | + level: 'warning', // warn => warning |
| 42 | + logger: 'console', |
| 43 | + extra: { |
| 44 | + arguments: ['Raven should capture console.warn'] |
| 45 | + } |
| 46 | + }); |
| 47 | + }); |
| 48 | +}); |
0 commit comments