11import '../mocks/mockInstabugUtils' ;
22
3- import { Platform } from 'react-native' ;
4-
53import * as CrashReporting from '../../src/modules/CrashReporting' ;
64import { NativeCrashReporting } from '../../src/native/NativeCrashReporting' ;
5+ import InstabugUtils from '../../src/utils/InstabugUtils' ;
76
87describe ( 'CrashReporting Module' , ( ) => {
98 it ( 'should call the native method setEnabled' , ( ) => {
@@ -13,39 +12,14 @@ describe('CrashReporting Module', () => {
1312 expect ( NativeCrashReporting . setEnabled ) . toBeCalledWith ( true ) ;
1413 } ) ;
1514
16- it ( 'should call the native method sendHandledJSCrash with JSON object when platform is iOS' , ( ) => {
17- Platform . OS = 'ios' ;
18- const error = { name : 'TypeError' , message : 'Invalid type' } ;
15+ it ( 'should call the native method sendCrashReporting with JSON object and sendHandledJsCrash as a callback' , ( ) => {
16+ const error = new TypeError ( 'Invalid type' ) ;
1917 CrashReporting . reportError ( error ) ;
2018
21- const expected = {
22- message : 'TypeError - Invalid type' ,
23- e_message : 'Invalid type' ,
24- e_name : 'TypeError' ,
25- os : 'ios' ,
26- platform : 'react_native' ,
27- exception : 'javascriptStackTrace' ,
28- } ;
29-
30- expect ( NativeCrashReporting . sendHandledJSCrash ) . toBeCalledTimes ( 1 ) ;
31- expect ( NativeCrashReporting . sendHandledJSCrash ) . toBeCalledWith ( expected ) ;
32- } ) ;
33-
34- it ( 'should call the native method sendHandledJSCrash with stringified JSON object when platform is Android' , ( ) => {
35- Platform . OS = 'android' ;
36- const error = { name : 'TypeError' , message : 'Invalid type' } ;
37- CrashReporting . reportError ( error ) ;
38-
39- const expected = JSON . stringify ( {
40- message : 'TypeError - Invalid type' ,
41- e_message : 'Invalid type' ,
42- e_name : 'TypeError' ,
43- os : 'android' ,
44- platform : 'react_native' ,
45- exception : 'javascriptStackTrace' ,
46- } ) ;
47-
48- expect ( NativeCrashReporting . sendHandledJSCrash ) . toBeCalledTimes ( 1 ) ;
49- expect ( NativeCrashReporting . sendHandledJSCrash ) . toBeCalledWith ( expected ) ;
19+ expect ( InstabugUtils . sendCrashReport ) . toBeCalledTimes ( 1 ) ;
20+ expect ( InstabugUtils . sendCrashReport ) . toBeCalledWith (
21+ error ,
22+ NativeCrashReporting . sendHandledJSCrash ,
23+ ) ;
5024 } ) ;
5125} ) ;
0 commit comments