1+ import { logger , setCurrentClient } from '@sentry/core' ;
2+ import { render } from '@testing-library/react-native' ;
13import * as React from 'react' ;
4+ import { Text } from 'react-native' ;
25
6+ import * as AppRegistry from '../src/js/integrations/appRegistry' ;
37import { wrap } from '../src/js/sdk' ;
8+ import { getDefaultTestClientOptions , TestClient } from './mocks/client' ;
49
510describe ( 'Sentry.wrap' , ( ) => {
611 it ( 'should not enforce any keys on the wrapped component' , ( ) => {
@@ -9,4 +14,23 @@ describe('Sentry.wrap', () => {
914
1015 expect ( typeof ActualWrapped . defaultProps ) . toBe ( typeof Mock . defaultProps ) ;
1116 } ) ;
17+
18+ it ( 'should wrap the component and init with a warning when getAppRegistryIntegration returns undefined' , ( ) => {
19+ logger . warn = jest . fn ( ) ;
20+ const getAppRegistryIntegration = jest . spyOn ( AppRegistry , 'getAppRegistryIntegration' ) . mockReturnValueOnce ( undefined ) ;
21+ const Mock : React . FC = ( ) => < Text > Test</ Text > ;
22+ const client = new TestClient (
23+ getDefaultTestClientOptions ( ) ,
24+ ) ;
25+ setCurrentClient ( client ) ;
26+
27+ client . init ( ) ;
28+ const ActualWrapped = wrap ( Mock ) ;
29+
30+ const { getByText } = render ( < ActualWrapped /> ) ;
31+
32+ expect ( getAppRegistryIntegration ) . toHaveBeenCalled ( ) ;
33+ expect ( logger . warn ) . toHaveBeenCalledWith ( 'AppRegistryIntegration.onRunApplication not found or invalid.' ) ;
34+ expect ( getByText ( 'Test' ) ) . toBeTruthy ( ) ;
35+ } ) ;
1236} ) ;
0 commit comments