|
| 1 | +var _Raven = require('../../src/raven'); |
| 2 | +var angularPlugin = require('../../plugins/angular'); |
| 3 | + |
| 4 | +var Raven; |
| 5 | +describe('Angular plugin', function () { |
| 6 | + beforeEach(function () { |
| 7 | + Raven = new _Raven(); |
| 8 | + Raven.config('http://[email protected]:80/2'); |
| 9 | + }); |
| 10 | + |
| 11 | + describe('_normalizeData()', function () { |
| 12 | + it('should extract type, value, and the angularDocs URL from unminified exceptions', function () { |
| 13 | + var data = { |
| 14 | + project: '2', |
| 15 | + logger: 'javascript', |
| 16 | + platform: 'javascript', |
| 17 | + |
| 18 | + culprit: 'http://example.org/app.js', |
| 19 | + message: 'Error: crap', |
| 20 | + exception: { |
| 21 | + type: 'Error', |
| 22 | + values: [{ |
| 23 | + value: |
| 24 | + '[ngRepeat:dupes] Duplicates in a repeater are not allowed. Use \'track by\' expression to specify unique keys. Repeater: element in elements | orderBy: \'createdAt\' track by element.id, Duplicate key: 25, Duplicate value: {"id":"booking-40"}\n' + |
| 25 | + 'http://errors.angularjs.org/1.4.3/ngRepeat/dupes?p0=element%20in%20elements…00%3A00%22%2C%22ends_at%22%3A%222016-06-09T23%3A59%3A59%2B00%3A00%22%7D%7D' |
| 26 | + }] |
| 27 | + }, |
| 28 | + extra: {} |
| 29 | + }; |
| 30 | + |
| 31 | + angularPlugin._normalizeData(data); |
| 32 | + |
| 33 | + var exception = data.exception.values[0]; |
| 34 | + assert.equal(exception.type, 'ngRepeat:dupes'); |
| 35 | + assert.equal(exception.value, 'Duplicates in a repeater are not allowed. Use \'track by\' expression to specify unique keys. Repeater: element in elements | orderBy: \'createdAt\' track by element.id, Duplicate key: 25, Duplicate value: {"id":"booking-40"}'); |
| 36 | + assert.equal(data.extra.angularDocs, 'http://errors.angularjs.org/1.4.3/ngRepeat/dupes?p0=element%20in%20elements…00%3A00%22%2C%22ends_at%22%3A%222016-06-09T23%3A59%3A59%2B00%3A00%22%7D%7D'); |
| 37 | + }); |
| 38 | + |
| 39 | + it('should extract type and the angularDocs URL minified exceptions', function () { |
| 40 | + var data = { |
| 41 | + project: '2', |
| 42 | + logger: 'javascript', |
| 43 | + platform: 'javascript', |
| 44 | + |
| 45 | + culprit: 'http://example.org/app.js', |
| 46 | + message: 'Error: crap', |
| 47 | + exception: { |
| 48 | + type: 'Error', |
| 49 | + values: [{ |
| 50 | + // no message, no newlines |
| 51 | + value: '[ngRepeat:dupes] http://errors.angularjs.org/1.4.3/ngRepeat/dupes?p0=element%20in%20elements…00%3A00%22%2C%22ends_at%22%3A%222016-06-09T23%3A59%3A59%2B00%3A00%22%7D%7D' |
| 52 | + }] |
| 53 | + }, |
| 54 | + extra: {} |
| 55 | + }; |
| 56 | + |
| 57 | + angularPlugin._normalizeData(data); |
| 58 | + |
| 59 | + var exception = data.exception.values[0]; |
| 60 | + assert.equal(exception.type, 'ngRepeat:dupes'); |
| 61 | + assert.equal(exception.value, ''); |
| 62 | + assert.equal(data.extra.angularDocs, 'http://errors.angularjs.org/1.4.3/ngRepeat/dupes?p0=element%20in%20elements…00%3A00%22%2C%22ends_at%22%3A%222016-06-09T23%3A59%3A59%2B00%3A00%22%7D%7D'); |
| 63 | + }); |
| 64 | + }); |
| 65 | +}); |
0 commit comments