|
| 1 | +import { expect } from 'chai'; |
| 2 | +import { prepareFramesForEvent } from '../src/parsers'; |
| 3 | + |
| 4 | +describe('Parsers', () => { |
| 5 | + describe('prepareFramesForEvent()', () => { |
| 6 | + describe('removed top frame if its internally reserved word (public API)', async () => { |
| 7 | + it('reserved captureException', () => { |
| 8 | + const stack = [ |
| 9 | + { context: ['x'], column: 1, line: 4, url: 'anything.js', func: 'captureException', args: [] }, |
| 10 | + { context: ['x'], column: 1, line: 3, url: 'anything.js', func: 'foo', args: [] }, |
| 11 | + { context: ['x'], column: 1, line: 2, url: 'anything.js', func: 'bar', args: [] }, |
| 12 | + ]; |
| 13 | + |
| 14 | + // Should remove `captureException` as its a name considered "internal" |
| 15 | + const frames = prepareFramesForEvent(stack); |
| 16 | + |
| 17 | + expect(frames.length).equal(2); |
| 18 | + expect(frames[0].function).equal('bar'); |
| 19 | + expect(frames[1].function).equal('foo'); |
| 20 | + }); |
| 21 | + |
| 22 | + it('reserved captureMessage', () => { |
| 23 | + const stack = [ |
| 24 | + { context: ['x'], column: 1, line: 4, url: 'anything.js', func: 'captureMessage', args: [] }, |
| 25 | + { context: ['x'], column: 1, line: 3, url: 'anything.js', func: 'foo', args: [] }, |
| 26 | + { context: ['x'], column: 1, line: 2, url: 'anything.js', func: 'bar', args: [] }, |
| 27 | + ]; |
| 28 | + |
| 29 | + // Should remove `captureMessage` as its a name considered "internal" |
| 30 | + const frames = prepareFramesForEvent(stack); |
| 31 | + |
| 32 | + expect(frames.length).equal(2); |
| 33 | + expect(frames[0].function).equal('bar'); |
| 34 | + expect(frames[1].function).equal('foo'); |
| 35 | + }); |
| 36 | + }); |
| 37 | + |
| 38 | + describe('removed bottom frame if its internally reserved word (internal API)', async () => { |
| 39 | + it('reserved sentryWrapped', () => { |
| 40 | + const stack = [ |
| 41 | + { context: ['x'], column: 1, line: 3, url: 'anything.js', func: 'foo', args: [] }, |
| 42 | + { context: ['x'], column: 1, line: 2, url: 'anything.js', func: 'bar', args: [] }, |
| 43 | + { context: ['x'], column: 1, line: 1, url: 'anything.js', func: 'sentryWrapped', args: [] }, |
| 44 | + ]; |
| 45 | + |
| 46 | + // Should remove `sentryWrapped` as its a name considered "internal" |
| 47 | + const frames = prepareFramesForEvent(stack); |
| 48 | + |
| 49 | + expect(frames.length).equal(2); |
| 50 | + expect(frames[0].function).equal('bar'); |
| 51 | + expect(frames[1].function).equal('foo'); |
| 52 | + }); |
| 53 | + }); |
| 54 | + |
| 55 | + it('removed top and bottom frame if they are internally reserved words', async () => { |
| 56 | + const stack = [ |
| 57 | + { context: ['x'], column: 1, line: 4, url: 'anything.js', func: 'captureMessage', args: [] }, |
| 58 | + { context: ['x'], column: 1, line: 3, url: 'anything.js', func: 'foo', args: [] }, |
| 59 | + { context: ['x'], column: 1, line: 2, url: 'anything.js', func: 'bar', args: [] }, |
| 60 | + { context: ['x'], column: 1, line: 1, url: 'anything.js', func: 'sentryWrapped', args: [] }, |
| 61 | + ]; |
| 62 | + |
| 63 | + // Should remove `captureMessage` and `sentryWrapped` as its a name considered "internal" |
| 64 | + const frames = prepareFramesForEvent(stack); |
| 65 | + |
| 66 | + expect(frames.length).equal(2); |
| 67 | + expect(frames[0].function).equal('bar'); |
| 68 | + expect(frames[1].function).equal('foo'); |
| 69 | + }); |
| 70 | + }); |
| 71 | +}); |
0 commit comments