1- import { ContextData } from '../ContextData' ;
21import { DefaultErrorParser } from '../../services/DefaultErrorParser' ;
32import { ExceptionlessClient } from '../../ExceptionlessClient' ;
4- import { IEvent } from '../../models/IEvent' ;
53import { EventPluginContext } from '../EventPluginContext' ;
64import { DuplicateCheckerPlugin } from './DuplicateCheckerPlugin' ;
7- import { ErrorPlugin } from './ErrorPlugin' ;
8- import { createFixture } from './EventPluginTestFixture' ;
95import { expect } from 'chai' ;
106
117describe ( '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