1- import { Scope } from '@sentry/core' ;
1+ import { captureCheckIn , getCurrentHub } from '@sentry/core' ;
22import type { Client , Integration } from '@sentry/types' ;
33
44import { installedIntegrations } from '../../src/integration' ;
@@ -10,31 +10,6 @@ declare var global: any;
1010
1111const PUBLIC_DSN = 'https://username@domain/123' ;
1212
13- jest . mock ( '@sentry/core' , ( ) => {
14- const original = jest . requireActual ( '@sentry/core' ) ;
15- return {
16- ...original ,
17- getCurrentHub ( ) : {
18- bindClient ( client : Client ) : boolean ;
19- getClient ( ) : boolean ;
20- getScope ( ) : Scope ;
21- } {
22- return {
23- getClient ( ) : boolean {
24- return false ;
25- } ,
26- getScope ( ) : Scope {
27- return new Scope ( ) ;
28- } ,
29- bindClient ( client : Client ) : boolean {
30- client . setupIntegrations ( ) ;
31- return true ;
32- } ,
33- } ;
34- } ,
35- } ;
36- } ) ;
37-
3813export class MockIntegration implements Integration {
3914 public name : string ;
4015 public setupOnce : ( ) => void = jest . fn ( ) ;
@@ -62,3 +37,23 @@ describe('SDK', () => {
6237 } ) ;
6338 } ) ;
6439} ) ;
40+
41+ describe ( 'captureCheckIn' , ( ) => {
42+ it ( 'returns an id when client is defined' , ( ) => {
43+ const hub = getCurrentHub ( ) ;
44+ jest . spyOn ( hub , 'getClient' ) . mockImplementation ( ( ) => {
45+ return {
46+ captureCheckIn : ( ) => 'some-id-wasd-1234' ,
47+ } as unknown as Client ;
48+ } ) ;
49+
50+ expect ( captureCheckIn ( { monitorSlug : 'gogogo' , status : 'in_progress' } ) ) . toStrictEqual ( expect . any ( String ) ) ;
51+ } ) ;
52+
53+ it ( 'returns an id when client is undefined' , ( ) => {
54+ const hub = getCurrentHub ( ) ;
55+ jest . spyOn ( hub , 'getClient' ) . mockImplementation ( ( ) => undefined ) ;
56+
57+ expect ( captureCheckIn ( { monitorSlug : 'gogogo' , status : 'in_progress' } ) ) . toStrictEqual ( expect . any ( String ) ) ;
58+ } ) ;
59+ } ) ;
0 commit comments