@@ -7,11 +7,13 @@ import { getCurrentHub, Hub, Scope } from '../src';
77
88const clientFn : any = jest . fn ( ) ;
99
10+ const MOCK_EVENT_ID = '7bab5137428b4de29891fb8bd34a31cb' ;
11+
1012function makeClient ( ) {
1113 return {
1214 getOptions : jest . fn ( ) ,
1315 captureEvent : jest . fn ( ) ,
14- captureException : jest . fn ( ) ,
16+ captureException : jest . fn ( ) . mockReturnValue ( MOCK_EVENT_ID ) ,
1517 close : jest . fn ( ) ,
1618 flush : jest . fn ( ) ,
1719 getDsn : jest . fn ( ) ,
@@ -224,14 +226,12 @@ describe('Hub', () => {
224226 expect ( args [ 0 ] ) . toBe ( 'a' ) ;
225227 } ) ;
226228
227- test ( 'should set event_id in hint ' , ( ) => {
229+ test ( 'should get event_id from client ' , ( ) => {
228230 const testClient = makeClient ( ) ;
229231 const hub = new Hub ( testClient ) ;
230232
231- hub . captureException ( 'a' ) ;
232- const args = getPassedArgs ( testClient . captureException ) ;
233-
234- expect ( args [ 1 ] . event_id ) . toBeTruthy ( ) ;
233+ const id = hub . captureException ( 'a' ) ;
234+ expect ( id ) . toBeDefined ( ) ;
235235 } ) ;
236236
237237 test ( 'should keep event_id from hint' , ( ) => {
@@ -270,14 +270,12 @@ describe('Hub', () => {
270270 expect ( args [ 0 ] ) . toBe ( 'a' ) ;
271271 } ) ;
272272
273- test ( 'should set event_id in hint ' , ( ) => {
273+ test ( 'should get event_id from client ' , ( ) => {
274274 const testClient = makeClient ( ) ;
275275 const hub = new Hub ( testClient ) ;
276276
277- hub . captureMessage ( 'a' ) ;
278- const args = getPassedArgs ( testClient . captureMessage ) ;
279-
280- expect ( args [ 2 ] . event_id ) . toBeTruthy ( ) ;
277+ const id = hub . captureMessage ( 'a' ) ;
278+ expect ( id ) . toBeDefined ( ) ;
281279 } ) ;
282280
283281 test ( 'should keep event_id from hint' , ( ) => {
@@ -318,17 +316,15 @@ describe('Hub', () => {
318316 expect ( args [ 0 ] ) . toBe ( event ) ;
319317 } ) ;
320318
321- test ( 'should set event_id in hint ' , ( ) => {
319+ test ( 'should get event_id from client ' , ( ) => {
322320 const event : Event = {
323321 extra : { b : 3 } ,
324322 } ;
325323 const testClient = makeClient ( ) ;
326324 const hub = new Hub ( testClient ) ;
327325
328- hub . captureEvent ( event ) ;
329- const args = getPassedArgs ( testClient . captureEvent ) ;
330-
331- expect ( args [ 1 ] . event_id ) . toBeTruthy ( ) ;
326+ const id = hub . captureEvent ( event ) ;
327+ expect ( id ) . toBeDefined ( ) ;
332328 } ) ;
333329
334330 test ( 'should keep event_id from hint' , ( ) => {
@@ -352,10 +348,8 @@ describe('Hub', () => {
352348 const testClient = makeClient ( ) ;
353349 const hub = new Hub ( testClient ) ;
354350
355- hub . captureEvent ( event ) ;
356- const args = getPassedArgs ( testClient . captureEvent ) ;
357-
358- expect ( args [ 1 ] . event_id ) . toEqual ( hub . lastEventId ( ) ) ;
351+ const id = hub . captureEvent ( event ) ;
352+ expect ( id ) . toEqual ( hub . lastEventId ( ) ) ;
359353 } ) ;
360354
361355 test ( 'transactions do not set lastEventId' , ( ) => {
@@ -366,10 +360,8 @@ describe('Hub', () => {
366360 const testClient = makeClient ( ) ;
367361 const hub = new Hub ( testClient ) ;
368362
369- hub . captureEvent ( event ) ;
370- const args = getPassedArgs ( testClient . captureEvent ) ;
371-
372- expect ( args [ 1 ] . event_id ) . not . toEqual ( hub . lastEventId ( ) ) ;
363+ const id = hub . captureEvent ( event ) ;
364+ expect ( id ) . not . toEqual ( hub . lastEventId ( ) ) ;
373365 } ) ;
374366 } ) ;
375367
0 commit comments