1
1
import { Scope } from '@sentry/hub' ;
2
2
import { Client , Integration } from '@sentry/types' ;
3
3
4
- import { getIntegrationsToSetup , installedIntegrations } from '../../src/integration' ;
4
+ import { installedIntegrations } from '../../src/integration' ;
5
5
import { initAndBind } from '../../src/sdk' ;
6
6
import { setupTestTransport , TestClient , getDefaultTestClientOptions } from '../mocks/client' ;
7
7
@@ -35,7 +35,7 @@ jest.mock('@sentry/hub', () => {
35
35
} ;
36
36
} ) ;
37
37
38
- class MockIntegration implements Integration {
38
+ export class MockIntegration implements Integration {
39
39
public name : string ;
40
40
public setupOnce : ( ) => void = jest . fn ( ) ;
41
41
public constructor ( name : string ) {
@@ -50,28 +50,6 @@ describe('SDK', () => {
50
50
} ) ;
51
51
52
52
describe ( 'initAndBind' , ( ) => {
53
- test ( 'installs default integrations' , ( ) => {
54
- const DEFAULT_INTEGRATIONS : Integration [ ] = [
55
- new MockIntegration ( 'MockIntegration 1' ) ,
56
- new MockIntegration ( 'MockIntegration 2' ) ,
57
- ] ;
58
- const options = getDefaultTestClientOptions ( { dsn : PUBLIC_DSN , integrations : DEFAULT_INTEGRATIONS } ) ;
59
- initAndBind ( TestClient , options , setupTestTransport ( options ) . transport ) ;
60
- expect ( ( DEFAULT_INTEGRATIONS [ 0 ] . setupOnce as jest . Mock ) . mock . calls . length ) . toBe ( 1 ) ;
61
- expect ( ( DEFAULT_INTEGRATIONS [ 1 ] . setupOnce as jest . Mock ) . mock . calls . length ) . toBe ( 1 ) ;
62
- } ) ;
63
-
64
- test ( "doesn't install default integrations if told not to" , ( ) => {
65
- const DEFAULT_INTEGRATIONS : Integration [ ] = [
66
- new MockIntegration ( 'MockIntegration 1' ) ,
67
- new MockIntegration ( 'MockIntegration 2' ) ,
68
- ] ;
69
- const options = getDefaultTestClientOptions ( { dsn : PUBLIC_DSN , defaultIntegrations : false } ) ;
70
- initAndBind ( TestClient , options , setupTestTransport ( options ) . transport ) ;
71
- expect ( ( DEFAULT_INTEGRATIONS [ 0 ] . setupOnce as jest . Mock ) . mock . calls . length ) . toBe ( 0 ) ;
72
- expect ( ( DEFAULT_INTEGRATIONS [ 1 ] . setupOnce as jest . Mock ) . mock . calls . length ) . toBe ( 0 ) ;
73
- } ) ;
74
-
75
53
test ( 'installs integrations provided through options' , ( ) => {
76
54
const integrations : Integration [ ] = [
77
55
new MockIntegration ( 'MockIntegration 1' ) ,
@@ -82,47 +60,5 @@ describe('SDK', () => {
82
60
expect ( ( integrations [ 0 ] . setupOnce as jest . Mock ) . mock . calls . length ) . toBe ( 1 ) ;
83
61
expect ( ( integrations [ 1 ] . setupOnce as jest . Mock ) . mock . calls . length ) . toBe ( 1 ) ;
84
62
} ) ;
85
-
86
- // TODO:
87
- test ( 'installs merged default integrations, with overrides provided through options' , ( ) => {
88
- const DEFAULT_INTEGRATIONS : Integration [ ] = [
89
- new MockIntegration ( 'MockIntegration 1' ) ,
90
- new MockIntegration ( 'MockIntegration 2' ) ,
91
- ] ;
92
- const integrations : Integration [ ] = [
93
- new MockIntegration ( 'MockIntegration 1' ) ,
94
- new MockIntegration ( 'MockIntegration 3' ) ,
95
- ] ;
96
- const options = getDefaultTestClientOptions ( {
97
- dsn : PUBLIC_DSN ,
98
- defaultIntegrations : DEFAULT_INTEGRATIONS ,
99
- integrations,
100
- } ) ;
101
- options . integrations = getIntegrationsToSetup ( options ) ;
102
-
103
- initAndBind ( TestClient , options , setupTestTransport ( options ) . transport ) ;
104
- // 'MockIntegration 1' should be overridden by the one with the same name provided through options
105
- expect ( ( DEFAULT_INTEGRATIONS [ 0 ] . setupOnce as jest . Mock ) . mock . calls . length ) . toBe ( 0 ) ;
106
- expect ( ( DEFAULT_INTEGRATIONS [ 1 ] . setupOnce as jest . Mock ) . mock . calls . length ) . toBe ( 1 ) ;
107
- expect ( ( integrations [ 0 ] . setupOnce as jest . Mock ) . mock . calls . length ) . toBe ( 1 ) ;
108
- expect ( ( integrations [ 1 ] . setupOnce as jest . Mock ) . mock . calls . length ) . toBe ( 1 ) ;
109
- } ) ;
110
-
111
- test . skip ( 'installs integrations returned from a callback function' , ( ) => {
112
- const DEFAULT_INTEGRATIONS : Integration [ ] = [
113
- new MockIntegration ( 'MockIntegration 1' ) ,
114
- new MockIntegration ( 'MockIntegration 2' ) ,
115
- ] ;
116
- const newIntegration = new MockIntegration ( 'MockIntegration 3' ) ;
117
- const options = getDefaultTestClientOptions ( {
118
- defaultIntegrations : DEFAULT_INTEGRATIONS ,
119
- dsn : PUBLIC_DSN ,
120
- // integrations: (integrations: Integration[]) => integrations.slice(0, 1).concat(newIntegration),
121
- } ) ;
122
- initAndBind ( TestClient , options , setupTestTransport ( options ) . transport ) ;
123
- expect ( ( DEFAULT_INTEGRATIONS [ 0 ] . setupOnce as jest . Mock ) . mock . calls . length ) . toBe ( 1 ) ;
124
- expect ( ( newIntegration . setupOnce as jest . Mock ) . mock . calls . length ) . toBe ( 1 ) ;
125
- expect ( ( DEFAULT_INTEGRATIONS [ 1 ] . setupOnce as jest . Mock ) . mock . calls . length ) . toBe ( 0 ) ;
126
- } ) ;
127
63
} ) ;
128
64
} ) ;
0 commit comments