@@ -47,7 +47,6 @@ const wrapper =
4747 onError,
4848 onEventError,
4949 events = defaultEvents ,
50- cdn,
5150 } : Omit < SegmentProviderProps < DefaultEvents > , 'children' > ) =>
5251 ( { children } : { children : ReactNode } ) =>
5352 (
@@ -57,7 +56,6 @@ const wrapper =
5756 onError = { onError }
5857 onEventError = { onEventError }
5958 events = { events }
60- cdn = { cdn }
6159 >
6260 { children }
6361 </ SegmentProvider >
@@ -69,9 +67,7 @@ describe('segment hook', () => {
6967 } )
7068
7169 it ( 'useSegment should not be defined without SegmentProvider' , ( ) => {
72- const { result } = renderHook ( ( ) => useSegment ( ) , {
73- wrapper : ( { children } ) => < div > { children } </ div > ,
74- } )
70+ const { result } = renderHook ( ( ) => useSegment ( ) )
7571 expect ( ( ) => {
7672 expect ( result . current ) . toBe ( undefined )
7773 } ) . toThrow ( Error ( 'useSegment must be used within a SegmentProvider' ) )
@@ -115,14 +111,12 @@ describe('segment hook', () => {
115111 . spyOn ( AnalyticsBrowser , 'load' )
116112 . mockResolvedValue ( [ { } as Analytics , { } as Context ] )
117113
118- const cdn = 'https://cdn.proxy'
119- const settings = { writeKey : 'helloworld' }
114+ const settings = { cdn : 'https://cdn.proxy' , writeKey : 'helloworld' }
120115
121116 const { result, waitForNextUpdate } = renderHook (
122117 ( ) => useSegment < DefaultEvents > ( ) ,
123118 {
124119 wrapper : wrapper ( {
125- cdn,
126120 events : defaultEvents ,
127121 settings,
128122 } ) ,
@@ -133,7 +127,6 @@ describe('segment hook', () => {
133127 expect ( mock ) . toHaveBeenCalledTimes ( 1 )
134128 expect ( mock ) . toHaveBeenCalledWith ( settings , undefined )
135129 expect ( result . current . analytics ) . toStrictEqual ( { } )
136- expect ( window . analytics ) . toStrictEqual ( { _cdn : cdn } )
137130 } )
138131
139132 it ( 'Provider should load and call onError on analytics load error' , async ( ) => {
@@ -232,21 +225,4 @@ describe('segment hook', () => {
232225 // @ts -expect-error if type infering works this should be an error
233226 expect ( await result . current . events . pageVisited ( ) ) . toBe ( undefined )
234227 } )
235-
236- it ( 'useSegment should correctly set cdn into windows.analitycs' , ( ) => {
237- // this test should be remove in the same time as this issues is solve
238- // https://github.com/segmentio/analytics-next/issues/362
239-
240- const cdn = 'https://cdn.segment.com/analytics.js'
241-
242- const { result } = renderHook ( ( ) => useSegment < DefaultEvents > ( ) , {
243- wrapper : wrapper ( {
244- cdn,
245- events : defaultEvents ,
246- settings : undefined ,
247- } ) ,
248- } )
249-
250- expect ( result . current . analytics ) . not . toBeNull ( )
251- } )
252228} )
0 commit comments