1
- import { ContextData } from '../ContextData' ;
2
1
import { DefaultErrorParser } from '../../services/DefaultErrorParser' ;
3
2
import { ExceptionlessClient } from '../../ExceptionlessClient' ;
4
- import { IEvent } from '../../models/IEvent' ;
5
3
import { EventPluginContext } from '../EventPluginContext' ;
6
4
import { DuplicateCheckerPlugin } from './DuplicateCheckerPlugin' ;
7
- import { ErrorPlugin } from './ErrorPlugin' ;
8
- import { createFixture } from './EventPluginTestFixture' ;
9
5
import { expect } from 'chai' ;
10
6
11
7
describe ( 'DuplicateCheckerPlugin' , ( ) => {
@@ -29,9 +25,7 @@ describe('DuplicateCheckerPlugin', () => {
29
25
}
30
26
31
27
it ( 'should ignore duplicate within window' , ( done ) => {
32
- let exception = createException ( [ {
33
- name : 'methodA'
34
- } ] ) ;
28
+ let exception = createException ( ) ;
35
29
run ( exception ) ;
36
30
37
31
let contextOfSecondRun = run ( exception ) ;
@@ -46,28 +40,25 @@ describe('DuplicateCheckerPlugin', () => {
46
40
} ) ;
47
41
48
42
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
+
50
46
run ( exception ) ;
51
47
let contextOfSecondRun = run ( exception ) ;
52
48
expect ( contextOfSecondRun . cancelled ) . not . to . be . true ;
53
49
} ) ;
54
50
55
51
it ( 'shouldn\'t ignore different stack within window' , ( ) => {
56
- let exception1 = createException ( [ {
57
- name : 'methodA'
58
- } ] ) ;
52
+ let exception1 = createException ( ) ;
59
53
run ( exception1 ) ;
60
- let exception2 = createException ( [ {
61
- name : 'methodB'
62
- } ] ) ;
54
+ let exception2 = createException2 ( ) ;
63
55
let contextOfSecondRun = run ( exception2 ) ;
56
+
64
57
expect ( contextOfSecondRun . cancelled ) . not . to . be . true ;
65
58
} ) ;
66
59
67
60
it ( 'shouldn\'t ignore duplicate after window' , ( ) => {
68
- let exception = createException ( [ {
69
- name : 'methodA'
70
- } ] ) ;
61
+ let exception = createException ( ) ;
71
62
run ( exception ) ;
72
63
73
64
now = 3000 ;
@@ -76,14 +67,24 @@ describe('DuplicateCheckerPlugin', () => {
76
67
} ) ;
77
68
} ) ;
78
69
79
- function createException ( stack ? ) {
70
+ function createException ( ) {
80
71
function throwError ( ) {
81
72
throw new ReferenceError ( 'This is a test' ) ;
82
73
}
83
74
try {
84
75
throwError ( ) ;
85
76
} 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 ) {
87
88
return e ;
88
89
}
89
90
}
0 commit comments