1
- import { Scope } from '@sentry/core' ;
1
+ import { captureCheckIn , getCurrentHub } from '@sentry/core' ;
2
2
import type { Client , Integration } from '@sentry/types' ;
3
3
4
4
import { installedIntegrations } from '../../src/integration' ;
@@ -10,31 +10,6 @@ declare var global: any;
10
10
11
11
const PUBLIC_DSN = 'https://username@domain/123' ;
12
12
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
-
38
13
export class MockIntegration implements Integration {
39
14
public name : string ;
40
15
public setupOnce : ( ) => void = jest . fn ( ) ;
@@ -62,3 +37,23 @@ describe('SDK', () => {
62
37
} ) ;
63
38
} ) ;
64
39
} ) ;
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