1
1
import { Integration } from '@sentry/types' ;
2
2
3
- import { ReportingObserver , ReportTypes } from '../src/reportingobserver' ;
3
+ import { ReportingObserver } from '../src/reportingobserver' ;
4
4
5
5
const mockScope = {
6
6
setExtra : jest . fn ( ) ,
@@ -72,7 +72,7 @@ describe('ReportingObserver', () => {
72
72
} ) ;
73
73
74
74
it ( 'should use user-provided report types' , ( ) => {
75
- const reportingObserverIntegration = new ReportingObserver ( { types : [ ReportTypes . Crash ] } ) ;
75
+ const reportingObserverIntegration = new ReportingObserver ( { types : [ 'crash' ] } ) ;
76
76
reportingObserverIntegration . setupOnce (
77
77
( ) => undefined ,
78
78
( ) => getMockHubWithIntegration ( reportingObserverIntegration ) as any ,
@@ -119,7 +119,7 @@ describe('ReportingObserver', () => {
119
119
) ;
120
120
121
121
expect ( ( ) => {
122
- reportingObserverIntegration . handler ( [ { type : ReportTypes . Crash , url : 'some url' } ] ) ;
122
+ reportingObserverIntegration . handler ( [ { type : 'crash' , url : 'some url' } ] ) ;
123
123
} ) . not . toThrow ( ) ;
124
124
125
125
expect ( mockHub . captureMessage ) . not . toHaveBeenCalled ( ) ;
@@ -133,8 +133,8 @@ describe('ReportingObserver', () => {
133
133
) ;
134
134
135
135
reportingObserverIntegration . handler ( [
136
- { type : ReportTypes . Crash , url : 'some url' } ,
137
- { type : ReportTypes . Deprecation , url : 'some url' } ,
136
+ { type : 'crash' , url : 'some url' } ,
137
+ { type : 'deprecation' , url : 'some url' } ,
138
138
] ) ;
139
139
140
140
expect ( mockHub . captureMessage ) . toHaveBeenCalledTimes ( 2 ) ;
@@ -148,8 +148,8 @@ describe('ReportingObserver', () => {
148
148
) ;
149
149
150
150
reportingObserverIntegration . handler ( [
151
- { type : ReportTypes . Crash , url : 'some url 1' } ,
152
- { type : ReportTypes . Deprecation , url : 'some url 2' } ,
151
+ { type : 'crash' , url : 'some url 1' } ,
152
+ { type : 'deprecation' , url : 'some url 2' } ,
153
153
] ) ;
154
154
155
155
expect ( mockScope . setExtra ) . toHaveBeenCalledWith ( 'url' , 'some url 1' ) ;
@@ -163,8 +163,8 @@ describe('ReportingObserver', () => {
163
163
( ) => getMockHubWithIntegration ( reportingObserverIntegration ) as any ,
164
164
) ;
165
165
166
- const report1 = { type : ReportTypes . Crash , url : 'some url 1' , body : { crashId : 'id1' } } ;
167
- const report2 = { type : ReportTypes . Deprecation , url : 'some url 2' , body : { id : 'id2' , message : 'message' } } ;
166
+ const report1 = { type : 'crash' , url : 'some url 1' , body : { crashId : 'id1' } } as const ;
167
+ const report2 = { type : 'deprecation' , url : 'some url 2' , body : { id : 'id2' , message : 'message' } } as const ;
168
168
169
169
reportingObserverIntegration . handler ( [ report1 , report2 ] ) ;
170
170
@@ -179,7 +179,7 @@ describe('ReportingObserver', () => {
179
179
( ) => getMockHubWithIntegration ( reportingObserverIntegration ) as any ,
180
180
) ;
181
181
182
- reportingObserverIntegration . handler ( [ { type : ReportTypes . Crash , url : 'some url' } ] ) ;
182
+ reportingObserverIntegration . handler ( [ { type : 'crash' , url : 'some url' } ] ) ;
183
183
184
184
expect ( mockScope . setExtra ) . not . toHaveBeenCalledWith ( 'body' , expect . anything ( ) ) ;
185
185
} ) ;
@@ -192,10 +192,10 @@ describe('ReportingObserver', () => {
192
192
) ;
193
193
194
194
const report = {
195
- type : ReportTypes . Crash ,
195
+ type : 'crash' ,
196
196
url : 'some url' ,
197
197
body : { crashId : 'some id' , reason : 'some reason' } ,
198
- } ;
198
+ } as const ;
199
199
reportingObserverIntegration . handler ( [ report ] ) ;
200
200
201
201
expect ( mockHub . captureMessage ) . toHaveBeenCalledWith ( expect . stringContaining ( report . type ) ) ;
@@ -211,10 +211,10 @@ describe('ReportingObserver', () => {
211
211
) ;
212
212
213
213
const report = {
214
- type : ReportTypes . Deprecation ,
214
+ type : 'deprecation' ,
215
215
url : 'some url' ,
216
216
body : { id : 'some id' , message : 'some message' } ,
217
- } ;
217
+ } as const ;
218
218
reportingObserverIntegration . handler ( [ report ] ) ;
219
219
220
220
expect ( mockHub . captureMessage ) . toHaveBeenCalledWith ( expect . stringContaining ( report . type ) ) ;
@@ -229,10 +229,10 @@ describe('ReportingObserver', () => {
229
229
) ;
230
230
231
231
const report = {
232
- type : ReportTypes . Intervention ,
232
+ type : 'intervention' ,
233
233
url : 'some url' ,
234
234
body : { id : 'some id' , message : 'some message' } ,
235
- } ;
235
+ } as const ;
236
236
reportingObserverIntegration . handler ( [ report ] ) ;
237
237
238
238
expect ( mockHub . captureMessage ) . toHaveBeenCalledWith ( expect . stringContaining ( report . type ) ) ;
@@ -247,9 +247,9 @@ describe('ReportingObserver', () => {
247
247
) ;
248
248
249
249
const report = {
250
- type : ReportTypes . Intervention ,
250
+ type : 'intervention' ,
251
251
url : 'some url' ,
252
- } ;
252
+ } as const ;
253
253
reportingObserverIntegration . handler ( [ report ] ) ;
254
254
255
255
expect ( mockHub . captureMessage ) . toHaveBeenCalledWith ( expect . stringContaining ( report . type ) ) ;
@@ -263,7 +263,7 @@ describe('ReportingObserver', () => {
263
263
( ) => getMockHubWithIntegration ( reportingObserverIntegration ) as any ,
264
264
) ;
265
265
266
- const report = { type : ReportTypes . Crash , url : 'some url' , body : { crashId : '' , reason : '' } } ;
266
+ const report = { type : 'crash' , url : 'some url' , body : { crashId : '' , reason : '' } } as const ;
267
267
reportingObserverIntegration . handler ( [ report ] ) ;
268
268
269
269
expect ( mockHub . captureMessage ) . toHaveBeenCalledWith ( expect . stringContaining ( report . type ) ) ;
@@ -278,10 +278,10 @@ describe('ReportingObserver', () => {
278
278
) ;
279
279
280
280
const report = {
281
- type : ReportTypes . Deprecation ,
281
+ type : 'deprecation' ,
282
282
url : 'some url' ,
283
283
body : { id : 'some id' , message : '' } ,
284
- } ;
284
+ } as const ;
285
285
reportingObserverIntegration . handler ( [ report ] ) ;
286
286
287
287
expect ( mockHub . captureMessage ) . toHaveBeenCalledWith ( expect . stringContaining ( report . type ) ) ;
@@ -296,10 +296,10 @@ describe('ReportingObserver', () => {
296
296
) ;
297
297
298
298
const report = {
299
- type : ReportTypes . Intervention ,
299
+ type : 'intervention' ,
300
300
url : 'some url' ,
301
301
body : { id : 'some id' , message : '' } ,
302
- } ;
302
+ } as const ;
303
303
reportingObserverIntegration . handler ( [ report ] ) ;
304
304
305
305
expect ( mockHub . captureMessage ) . toHaveBeenCalledWith ( expect . stringContaining ( report . type ) ) ;
0 commit comments