@@ -6,19 +6,10 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
6
6
7
7
import { SDK_VERSION } from '@sentry/browser' ;
8
8
import * as SentryBrowser from '@sentry/browser' ;
9
- import type { EventProcessor } from '@sentry/core' ;
10
9
11
- import { detectAndReportSvelteKit , init as svelteInit , isSvelteKitApp } from '../src/sdk' ;
12
-
13
- let passedEventProcessor : EventProcessor | undefined ;
10
+ import { init as svelteInit } from '../src/sdk' ;
14
11
15
12
const browserInit = vi . spyOn ( SentryBrowser , 'init' ) ;
16
- const addEventProcessor = vi
17
- . spyOn ( SentryBrowser , 'addEventProcessor' )
18
- . mockImplementation ( ( eventProcessor : EventProcessor ) => {
19
- passedEventProcessor = eventProcessor ;
20
- return ( ) => { } ;
21
- } ) ;
22
13
23
14
describe ( 'Initialize Svelte SDk' , ( ) => {
24
15
beforeEach ( ( ) => {
@@ -84,54 +75,3 @@ describe('Initialize Svelte SDk', () => {
84
75
expect ( client ) . not . toBeUndefined ( ) ;
85
76
} ) ;
86
77
} ) ;
87
-
88
- describe ( 'detectAndReportSvelteKit()' , ( ) => {
89
- const originalHtmlBody = document . body . innerHTML ;
90
- beforeEach ( ( ) => {
91
- vi . clearAllMocks ( ) ;
92
- document . body . innerHTML = originalHtmlBody ;
93
- passedEventProcessor = undefined ;
94
- } ) ;
95
-
96
- it ( 'registers an event processor' , async ( ) => {
97
- detectAndReportSvelteKit ( ) ;
98
-
99
- expect ( addEventProcessor ) . toHaveBeenCalledTimes ( 1 ) ;
100
- expect ( passedEventProcessor ?. id ) . toEqual ( 'svelteKitProcessor' ) ;
101
- } ) ;
102
-
103
- it ( 'adds "SvelteKit" as a module to the event, if SvelteKit was detected' , ( ) => {
104
- document . body . innerHTML += '<div id="svelte-announcer">Home</div>' ;
105
- detectAndReportSvelteKit ( ) ;
106
-
107
- const processedEvent = passedEventProcessor ?.( { } as unknown as any , { } ) ;
108
-
109
- expect ( processedEvent ) . toBeDefined ( ) ;
110
- expect ( processedEvent ) . toEqual ( { modules : { svelteKit : 'latest' } } ) ;
111
- } ) ;
112
-
113
- it ( "doesn't add anything to the event, if SvelteKit was not detected" , ( ) => {
114
- document . body . innerHTML = '' ;
115
- detectAndReportSvelteKit ( ) ;
116
-
117
- const processedEvent = passedEventProcessor ?.( { } as unknown as any , { } ) ;
118
-
119
- expect ( processedEvent ) . toBeDefined ( ) ;
120
- expect ( processedEvent ) . toEqual ( { } ) ;
121
- } ) ;
122
-
123
- describe ( 'isSvelteKitApp()' , ( ) => {
124
- it ( 'returns true if the svelte-announcer div is present' , ( ) => {
125
- document . body . innerHTML += '<div id="svelte-announcer">Home</div>' ;
126
- expect ( isSvelteKitApp ( ) ) . toBe ( true ) ;
127
- } ) ;
128
- it ( 'returns false if the svelte-announcer div is not present (but similar elements)' , ( ) => {
129
- document . body . innerHTML += '<div id="svelte-something">Home</div>' ;
130
- expect ( isSvelteKitApp ( ) ) . toBe ( false ) ;
131
- } ) ;
132
- it ( 'returns false if no div is present' , ( ) => {
133
- document . body . innerHTML = '' ;
134
- expect ( isSvelteKitApp ( ) ) . toBe ( false ) ;
135
- } ) ;
136
- } ) ;
137
- } ) ;
0 commit comments