@@ -7,100 +7,102 @@ import "react-native";
77import { NativeModules , Platform } from "react-native" ;
88import "./jest/mockAPM" ;
99import APM from "../src/modules/APM" ;
10- import sinon from "sinon" ;
1110
1211import IBGEventEmitter from "../src/utils/IBGEventEmitter" ;
1312
14- describe ( "APM Module" , ( ) => {
15- const setEnabled = sinon . spy ( NativeModules . IBGAPM , "setEnabled" ) ;
16- const setAppLaunchEnabled = sinon . spy ( NativeModules . IBGAPM , "setAppLaunchEnabled" ) ;
17- const setLogLevel = sinon . spy ( NativeModules . IBGAPM , "setLogLevel" ) ;
18- const setAutoUITraceEnabled = sinon . spy ( NativeModules . IBGAPM , "setAutoUITraceEnabled" ) ;
19- const startExecutionTrace = sinon . spy ( NativeModules . IBGAPM , "startExecutionTrace" ) ;
20- const setExecutionTraceAttribute = sinon . spy ( NativeModules . IBGAPM , "setExecutionTraceAttribute" ) ;
21- const endExecutionTrace = sinon . spy ( NativeModules . IBGAPM , "endExecutionTrace" ) ;
22- const startUITrace = sinon . spy ( NativeModules . IBGAPM , "startUITrace" ) ;
23- const endUITrace = sinon . spy ( NativeModules . IBGAPM , "endUITrace" ) ;
24- const endAppLaunch = sinon . spy ( NativeModules . IBGAPM , "endAppLaunch" ) ;
25- const setNetworkLoggingEnabled = sinon . spy ( NativeModules . Instabug , "setNetworkLoggingEnabled" ) ;
26- const _ibgSleep = sinon . spy ( NativeModules . IBGAPM , "ibgSleep" ) ;
13+ const { Instabug : NativeInstabug , IBGAPM : NativeIBGAPM } = NativeModules ;
2714
15+ describe ( "APM Module" , ( ) => {
2816 beforeEach ( ( ) => {
2917 IBGEventEmitter . removeAllListeners ( ) ;
3018 } ) ;
3119
3220 it ( "should call the native method setEnabled" , ( ) => {
3321 APM . setEnabled ( true ) ;
3422
35- expect ( setEnabled . calledOnceWithExactly ( true ) ) . toBe ( true ) ;
23+ expect ( NativeIBGAPM . setEnabled ) . toBeCalledTimes ( 1 ) ;
24+ expect ( NativeIBGAPM . setEnabled ) . toBeCalledWith ( true ) ;
3625 } ) ;
3726
3827 it ( "should call the native method setAppLaunchEnabled" , ( ) => {
3928 APM . setAppLaunchEnabled ( true ) ;
4029
41- expect ( setAppLaunchEnabled . calledOnceWithExactly ( true ) ) . toBe ( true ) ;
30+ expect ( NativeIBGAPM . setAppLaunchEnabled ) . toBeCalledTimes ( 1 ) ;
31+ expect ( NativeIBGAPM . setAppLaunchEnabled ) . toBeCalledWith ( true ) ;
4232 } ) ;
4333
4434 it ( "should call the native method setNetworkEnabledIOS" , ( ) => {
4535 Platform . OS = 'ios' ;
4636 APM . setNetworkEnabledIOS ( true ) ;
4737
48- expect ( setNetworkLoggingEnabled . calledOnceWithExactly ( true ) ) . toBe ( true ) ;
38+ expect ( NativeInstabug . setNetworkLoggingEnabled ) . toBeCalledTimes ( 1 ) ;
39+ expect ( NativeInstabug . setNetworkLoggingEnabled ) . toBeCalledWith ( true ) ;
4940 } ) ;
5041
5142 it ( "should call the native method endAppLaunch" , ( ) => {
5243 APM . endAppLaunch ( ) ;
5344
54- expect ( endAppLaunch . calledOnceWithExactly ( ) ) . toBe ( true ) ;
45+ expect ( NativeIBGAPM . endAppLaunch ) . toBeCalledTimes ( 1 ) ;
46+ expect ( NativeIBGAPM . endAppLaunch ) . toBeCalledWith ( ) ;
5547 } ) ;
5648
5749 it ( "should call the native method setAutoUITraceEnabled" , ( ) => {
5850 APM . setAutoUITraceEnabled ( true ) ;
5951
60- expect ( setAutoUITraceEnabled . calledOnceWithExactly ( true ) ) . toBe ( true ) ;
52+ expect ( NativeIBGAPM . setAutoUITraceEnabled ) . toBeCalledTimes ( 1 ) ;
53+ expect ( NativeIBGAPM . setAutoUITraceEnabled ) . toBeCalledWith ( true ) ;
6154 } ) ;
6255
6356 it ( "should call the native method setLogLevel" , ( ) => {
6457 APM . setLogLevel ( APM . logLevel . verbose ) ;
6558
66- expect ( setLogLevel . calledOnceWithExactly ( APM . logLevel . verbose ) ) . toBe ( true ) ;
59+ expect ( NativeIBGAPM . setLogLevel ) . toBeCalledTimes ( 1 ) ;
60+ expect ( NativeIBGAPM . setLogLevel ) . toBeCalledWith ( APM . logLevel . verbose ) ;
6761 } ) ;
6862
6963 it ( "should call the native method startExecutionTrace" , ( ) => {
7064 APM . startExecutionTrace ( "trace" ) ;
7165
72- expect ( startExecutionTrace . calledOnceWith ( "trace" ) ) . toBe ( true ) ;
66+ expect ( NativeIBGAPM . startExecutionTrace ) . toBeCalledTimes ( 1 ) ;
67+ expect ( NativeIBGAPM . startExecutionTrace ) . toBeCalledWith ( "trace" , expect . any ( String ) , expect . any ( Function ) ) ;
7368 } ) ;
7469
7570 it ( "should call the native method setExecutionTraceAttribute" , ( ) => {
7671 const trace = APM . startExecutionTrace ( "trace" ) . then ( ( ) => {
7772 trace . setAttribute ( "key" , "value" ) ;
78- expect ( setExecutionTraceAttribute . calledOnceWithExactly ( expect . any ( String ) , "key" , "value" ) ) . toBe ( true ) ;
73+
74+ expect ( NativeIBGAPM . setExecutionTraceAttribute ) . toBeCalledTimes ( 1 ) ;
75+ expect ( NativeIBGAPM . setExecutionTraceAttribute ) . toBeCalledWith ( expect . any ( String ) , "key" , "value" ) ;
7976 } ) ;
8077 } ) ;
8178
8279 it ( "should call the native method endExecutionTrace" , ( ) => {
8380 const trace = APM . startExecutionTrace ( "trace" ) . then ( ( ) => {
8481 trace . end ( ) ;
85- expect ( endExecutionTrace . calledOnceWithExactly ( expect . any ( String ) ) ) . toBe ( true ) ;
82+
83+ expect ( NativeIBGAPM . endExecutionTrace ) . toBeCalledTimes ( 1 ) ;
84+ expect ( NativeIBGAPM . endExecutionTrace ) . toBeCalledWith ( expect . any ( String ) ) ;
8685 } ) ;
8786 } ) ;
8887
8988 it ( "should call the native method startUITrace" , ( ) => {
9089 APM . startUITrace ( "uiTrace" ) ;
9190
92- expect ( startUITrace . calledOnceWithExactly ( "uiTrace" ) ) . toBe ( true ) ;
91+ expect ( NativeIBGAPM . startUITrace ) . toBeCalledTimes ( 1 ) ;
92+ expect ( NativeIBGAPM . startUITrace ) . toBeCalledWith ( "uiTrace" ) ;
9393 } ) ;
9494
9595 it ( "should call the native method endUITrace" , ( ) => {
9696 APM . endUITrace ( ) ;
9797
98- expect ( endUITrace . calledOnceWithExactly ( ) ) . toBe ( true ) ;
98+ expect ( NativeIBGAPM . endUITrace ) . toBeCalledTimes ( 1 ) ;
99+ expect ( NativeIBGAPM . endUITrace ) . toBeCalledWith ( ) ;
99100 } ) ;
100101
101102 it ( "should call the native method _ibgSleep" , ( ) => {
102103 APM . _ibgSleep ( ) ;
103104
104- expect ( _ibgSleep . calledOnceWithExactly ( ) ) . toBe ( true ) ;
105+ expect ( NativeIBGAPM . ibgSleep ) . toBeCalledTimes ( 1 ) ;
106+ expect ( NativeIBGAPM . ibgSleep ) . toBeCalledWith ( ) ;
105107 } ) ;
106108} ) ;
0 commit comments