Skip to content

Commit 082f018

Browse files
authored
Enable disabled InstabugUtils test (#792)
1 parent 7989a83 commit 082f018

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

tests/utils/InstabugUtils.spec.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import '../mocks/mockXhrNetworkInterceptor';
22
import { NativeModules, Platform } from 'react-native';
33
import Instabug from '../../src';
4+
import InstabugUtils from '../../src/utils/InstabugUtils';
5+
import IBGEventEmitter from '../../src/utils/IBGEventEmitter';
6+
import IBGConstants from '../../src/utils/InstabugConstants';
47

58
const { Instabug: NativeInstabug } = NativeModules;
69

@@ -26,20 +29,21 @@ describe('Test global error handler', () => {
2629
expect(NativeInstabug.sendJSCrash).toHaveBeenCalledWith(expected);
2730
});
2831

29-
// it('should emit event IBGSendUnhandledJSCrash when platform is android and onReportSubmitHandler is set', (done) => {
30-
// Platform.OS = 'android';
31-
// Instabug._isOnReportHandlerSet = jest.fn(() => true);
32-
// const handler = global.ErrorUtils.getGlobalHandler();
33-
// IBGEventEmitter.addListener(Instabug, IBGConstants.SEND_UNHANDLED_CRASH, (actual) => {
34-
// const expected = {
35-
// message: 'TypeError - This is a type error.',
36-
// os: 'android',
37-
// platform: 'react_native',
38-
// exception: []
39-
// };
40-
// expect(actual).toEqual(expected);
41-
// done();
42-
// });
43-
// handler({ name: 'TypeError', message: 'This is a type error.' }, false);
44-
// });
32+
it('should emit event IBGSendUnhandledJSCrash when platform is android and onReportSubmitHandler is set', () => {
33+
Platform.OS = 'android';
34+
InstabugUtils.setOnReportHandler(true);
35+
const handler = global.ErrorUtils.getGlobalHandler();
36+
const callback = jest.fn();
37+
IBGEventEmitter.addListener(Instabug, IBGConstants.SEND_UNHANDLED_CRASH, callback);
38+
handler({ name: 'TypeError', message: 'This is a type error.' }, false);
39+
40+
expect(callback).toHaveBeenCalledWith({
41+
message: 'TypeError - This is a type error.',
42+
e_message: 'This is a type error.',
43+
e_name: 'TypeError',
44+
os: 'android',
45+
platform: 'react_native',
46+
exception: [],
47+
});
48+
});
4549
});

0 commit comments

Comments
 (0)