11import { Integration } from '@sentry/types' ;
22
3- import { ReportingObserver , ReportTypes } from '../src/reportingobserver' ;
3+ import { ReportingObserver } from '../src/reportingobserver' ;
44
55const mockScope = {
66 setExtra : jest . fn ( ) ,
@@ -72,7 +72,7 @@ describe('ReportingObserver', () => {
7272 } ) ;
7373
7474 it ( 'should use user-provided report types' , ( ) => {
75- const reportingObserverIntegration = new ReportingObserver ( { types : [ ReportTypes . Crash ] } ) ;
75+ const reportingObserverIntegration = new ReportingObserver ( { types : [ 'crash' ] } ) ;
7676 reportingObserverIntegration . setupOnce (
7777 ( ) => undefined ,
7878 ( ) => getMockHubWithIntegration ( reportingObserverIntegration ) as any ,
@@ -119,7 +119,7 @@ describe('ReportingObserver', () => {
119119 ) ;
120120
121121 expect ( ( ) => {
122- reportingObserverIntegration . handler ( [ { type : ReportTypes . Crash , url : 'some url' } ] ) ;
122+ reportingObserverIntegration . handler ( [ { type : 'crash' , url : 'some url' } ] ) ;
123123 } ) . not . toThrow ( ) ;
124124
125125 expect ( mockHub . captureMessage ) . not . toHaveBeenCalled ( ) ;
@@ -133,8 +133,8 @@ describe('ReportingObserver', () => {
133133 ) ;
134134
135135 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' } ,
138138 ] ) ;
139139
140140 expect ( mockHub . captureMessage ) . toHaveBeenCalledTimes ( 2 ) ;
@@ -148,8 +148,8 @@ describe('ReportingObserver', () => {
148148 ) ;
149149
150150 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' } ,
153153 ] ) ;
154154
155155 expect ( mockScope . setExtra ) . toHaveBeenCalledWith ( 'url' , 'some url 1' ) ;
@@ -163,8 +163,8 @@ describe('ReportingObserver', () => {
163163 ( ) => getMockHubWithIntegration ( reportingObserverIntegration ) as any ,
164164 ) ;
165165
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 ;
168168
169169 reportingObserverIntegration . handler ( [ report1 , report2 ] ) ;
170170
@@ -179,7 +179,7 @@ describe('ReportingObserver', () => {
179179 ( ) => getMockHubWithIntegration ( reportingObserverIntegration ) as any ,
180180 ) ;
181181
182- reportingObserverIntegration . handler ( [ { type : ReportTypes . Crash , url : 'some url' } ] ) ;
182+ reportingObserverIntegration . handler ( [ { type : 'crash' , url : 'some url' } ] ) ;
183183
184184 expect ( mockScope . setExtra ) . not . toHaveBeenCalledWith ( 'body' , expect . anything ( ) ) ;
185185 } ) ;
@@ -192,10 +192,10 @@ describe('ReportingObserver', () => {
192192 ) ;
193193
194194 const report = {
195- type : ReportTypes . Crash ,
195+ type : 'crash' ,
196196 url : 'some url' ,
197197 body : { crashId : 'some id' , reason : 'some reason' } ,
198- } ;
198+ } as const ;
199199 reportingObserverIntegration . handler ( [ report ] ) ;
200200
201201 expect ( mockHub . captureMessage ) . toHaveBeenCalledWith ( expect . stringContaining ( report . type ) ) ;
@@ -211,10 +211,10 @@ describe('ReportingObserver', () => {
211211 ) ;
212212
213213 const report = {
214- type : ReportTypes . Deprecation ,
214+ type : 'deprecation' ,
215215 url : 'some url' ,
216216 body : { id : 'some id' , message : 'some message' } ,
217- } ;
217+ } as const ;
218218 reportingObserverIntegration . handler ( [ report ] ) ;
219219
220220 expect ( mockHub . captureMessage ) . toHaveBeenCalledWith ( expect . stringContaining ( report . type ) ) ;
@@ -229,10 +229,10 @@ describe('ReportingObserver', () => {
229229 ) ;
230230
231231 const report = {
232- type : ReportTypes . Intervention ,
232+ type : 'intervention' ,
233233 url : 'some url' ,
234234 body : { id : 'some id' , message : 'some message' } ,
235- } ;
235+ } as const ;
236236 reportingObserverIntegration . handler ( [ report ] ) ;
237237
238238 expect ( mockHub . captureMessage ) . toHaveBeenCalledWith ( expect . stringContaining ( report . type ) ) ;
@@ -247,9 +247,9 @@ describe('ReportingObserver', () => {
247247 ) ;
248248
249249 const report = {
250- type : ReportTypes . Intervention ,
250+ type : 'intervention' ,
251251 url : 'some url' ,
252- } ;
252+ } as const ;
253253 reportingObserverIntegration . handler ( [ report ] ) ;
254254
255255 expect ( mockHub . captureMessage ) . toHaveBeenCalledWith ( expect . stringContaining ( report . type ) ) ;
@@ -263,7 +263,7 @@ describe('ReportingObserver', () => {
263263 ( ) => getMockHubWithIntegration ( reportingObserverIntegration ) as any ,
264264 ) ;
265265
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 ;
267267 reportingObserverIntegration . handler ( [ report ] ) ;
268268
269269 expect ( mockHub . captureMessage ) . toHaveBeenCalledWith ( expect . stringContaining ( report . type ) ) ;
@@ -278,10 +278,10 @@ describe('ReportingObserver', () => {
278278 ) ;
279279
280280 const report = {
281- type : ReportTypes . Deprecation ,
281+ type : 'deprecation' ,
282282 url : 'some url' ,
283283 body : { id : 'some id' , message : '' } ,
284- } ;
284+ } as const ;
285285 reportingObserverIntegration . handler ( [ report ] ) ;
286286
287287 expect ( mockHub . captureMessage ) . toHaveBeenCalledWith ( expect . stringContaining ( report . type ) ) ;
@@ -296,10 +296,10 @@ describe('ReportingObserver', () => {
296296 ) ;
297297
298298 const report = {
299- type : ReportTypes . Intervention ,
299+ type : 'intervention' ,
300300 url : 'some url' ,
301301 body : { id : 'some id' , message : '' } ,
302- } ;
302+ } as const ;
303303 reportingObserverIntegration . handler ( [ report ] ) ;
304304
305305 expect ( mockHub . captureMessage ) . toHaveBeenCalledWith ( expect . stringContaining ( report . type ) ) ;
0 commit comments