1
- import { logger } from '@sentry/core' ;
1
+ import { getClient , logger , setCurrentClient } from '@sentry/core' ;
2
2
import { render } from '@testing-library/react-native' ;
3
3
import * as React from 'react' ;
4
4
import { Text } from 'react-native' ;
5
5
6
6
import { defaultConfiguration } from '../../src/js/feedback/defaults' ;
7
7
import { FeedbackWidgetProvider , resetFeedbackWidgetManager , showFeedbackWidget } from '../../src/js/feedback/FeedbackWidgetManager' ;
8
8
import { feedbackIntegration } from '../../src/js/feedback/integration' ;
9
+ import { AUTO_INJECT_FEEDBACK_INTEGRATION_NAME } from '../../src/js/feedback/lazy' ;
9
10
import { isModalSupported } from '../../src/js/feedback/utils' ;
11
+ import { getDefaultTestClientOptions , TestClient } from '../mocks/client' ;
10
12
11
13
jest . mock ( '../../src/js/feedback/utils' , ( ) => ( {
12
14
isModalSupported : jest . fn ( ) ,
@@ -23,6 +25,9 @@ beforeEach(() => {
23
25
describe ( 'FeedbackWidgetManager' , ( ) => {
24
26
25
27
beforeEach ( ( ) => {
28
+ const client = new TestClient ( getDefaultTestClientOptions ( ) ) ;
29
+ setCurrentClient ( client ) ;
30
+ client . init ( ) ;
26
31
consoleWarnSpy . mockReset ( ) ;
27
32
resetFeedbackWidgetManager ( ) ;
28
33
} ) ;
@@ -72,10 +77,11 @@ describe('FeedbackWidgetManager', () => {
72
77
</ FeedbackWidgetProvider >
73
78
) ;
74
79
75
- feedbackIntegration ( {
80
+ const integration = feedbackIntegration ( {
76
81
messagePlaceholder : 'Custom Message Placeholder' ,
77
82
submitButtonLabel : 'Custom Submit Button' ,
78
83
} ) ;
84
+ getClient ( ) ?. addIntegration ( integration ) ;
79
85
80
86
showFeedbackWidget ( ) ;
81
87
@@ -91,9 +97,10 @@ describe('FeedbackWidgetManager', () => {
91
97
</ FeedbackWidgetProvider >
92
98
) ;
93
99
94
- feedbackIntegration ( {
100
+ const integration = feedbackIntegration ( {
95
101
submitButtonLabel : 'Custom Submit Button' ,
96
- } ) ,
102
+ } ) ;
103
+ getClient ( ) ?. addIntegration ( integration ) ;
97
104
98
105
showFeedbackWidget ( ) ;
99
106
@@ -123,4 +130,12 @@ describe('FeedbackWidgetManager', () => {
123
130
124
131
expect ( consoleWarnSpy ) . not . toHaveBeenCalled ( ) ;
125
132
} ) ;
133
+
134
+ it ( 'showFeedbackWidget adds the feedbackIntegration to the client' , ( ) => {
135
+ mockedIsModalSupported . mockReturnValue ( true ) ;
136
+
137
+ showFeedbackWidget ( ) ;
138
+
139
+ expect ( getClient ( ) . getIntegrationByName ( AUTO_INJECT_FEEDBACK_INTEGRATION_NAME ) ) . toBeDefined ( ) ;
140
+ } ) ;
126
141
} ) ;
0 commit comments