Skip to content

Commit 0fc7f0c

Browse files
committed
Cleanup and make sure we have stacks
make sure we have different stacks when the tests call for it make sure we have a stack when needed
1 parent fd0f3bb commit 0fc7f0c

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

src/plugins/default/DuplicateCheckerPlugin-spec.ts

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
import { ContextData } from '../ContextData';
21
import { DefaultErrorParser } from '../../services/DefaultErrorParser';
32
import { ExceptionlessClient } from '../../ExceptionlessClient';
4-
import { IEvent } from '../../models/IEvent';
53
import { EventPluginContext } from '../EventPluginContext';
64
import { DuplicateCheckerPlugin } from './DuplicateCheckerPlugin';
7-
import { ErrorPlugin } from './ErrorPlugin';
8-
import { createFixture } from './EventPluginTestFixture';
95
import { expect } from 'chai';
106

117
describe('DuplicateCheckerPlugin', () => {
@@ -29,9 +25,7 @@ describe('DuplicateCheckerPlugin', () => {
2925
}
3026

3127
it('should ignore duplicate within window', (done) => {
32-
let exception = createException([{
33-
name: 'methodA'
34-
}]);
28+
let exception = createException();
3529
run(exception);
3630

3731
let contextOfSecondRun = run(exception);
@@ -46,28 +40,25 @@ describe('DuplicateCheckerPlugin', () => {
4640
});
4741

4842
it('shouldn\'t ignore error without stack', () => {
49-
let exception = createException();
43+
let exception = new ReferenceError('This is a test');
44+
delete exception.stack;
45+
5046
run(exception);
5147
let contextOfSecondRun = run(exception);
5248
expect(contextOfSecondRun.cancelled).not.to.be.true;
5349
});
5450

5551
it('shouldn\'t ignore different stack within window', () => {
56-
let exception1 = createException([{
57-
name: 'methodA'
58-
}]);
52+
let exception1 = createException();
5953
run(exception1);
60-
let exception2 = createException([{
61-
name: 'methodB'
62-
}]);
54+
let exception2 = createException2();
6355
let contextOfSecondRun = run(exception2);
56+
6457
expect(contextOfSecondRun.cancelled).not.to.be.true;
6558
});
6659

6760
it('shouldn\'t ignore duplicate after window', () => {
68-
let exception = createException([{
69-
name: 'methodA'
70-
}]);
61+
let exception = createException();
7162
run(exception);
7263

7364
now = 3000;
@@ -76,14 +67,24 @@ describe('DuplicateCheckerPlugin', () => {
7667
});
7768
});
7869

79-
function createException(stack?) {
70+
function createException() {
8071
function throwError() {
8172
throw new ReferenceError('This is a test');
8273
}
8374
try {
8475
throwError();
8576
} catch (e) {
86-
e.testStack = stack;
77+
return e;
78+
}
79+
}
80+
81+
function createException2() {
82+
function throwError2() {
83+
throw new ReferenceError('This is a test');
84+
}
85+
try {
86+
throwError2();
87+
} catch (e) {
8788
return e;
8889
}
8990
}

0 commit comments

Comments
 (0)