File tree Expand file tree Collapse file tree
components/stream-creation Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import '@testing-library/jest-dom' ;
2+ import { vi } from 'vitest' ;
3+
4+ const localStorageMock = ( ( ) => {
5+ let store : Record < string , string > = { } ;
6+ return {
7+ getItem : vi . fn ( ( key : string ) => store [ key ] || null ) ,
8+ setItem : vi . fn ( ( key : string , value : string ) => {
9+ store [ key ] = value . toString ( ) ;
10+ } ) ,
11+ clear : vi . fn ( ( ) => {
12+ store = { } ;
13+ } ) ,
14+ removeItem : vi . fn ( ( key : string ) => {
15+ delete store [ key ] ;
16+ } ) ,
17+ key : vi . fn ( ( index : number ) => Object . keys ( store ) [ index ] || null ) ,
18+ length : 0 ,
19+ } ;
20+ } ) ( ) ;
21+
22+ vi . stubGlobal ( 'localStorage' , localStorageMock ) ;
23+ if ( typeof window !== 'undefined' ) {
24+ Object . defineProperty ( window , 'localStorage' , {
25+ value : localStorageMock ,
26+ configurable : true ,
27+ writable : true ,
28+ } ) ;
29+ }
30+
Original file line number Diff line number Diff line change @@ -321,7 +321,7 @@ export const StreamCreationWizard: React.FC<StreamCreationWizardProps> = ({
321321 setCurrentStep ( currentStep + 1 ) ;
322322 // Scroll to top when moving to next step
323323 const modal = document . querySelector ( '.glass-card' ) ;
324- if ( modal ) {
324+ if ( modal && typeof modal . scrollTo === 'function' ) {
325325 modal . scrollTo ( { top : 0 , behavior : 'smooth' } ) ;
326326 }
327327 }
@@ -338,7 +338,9 @@ export const StreamCreationWizard: React.FC<StreamCreationWizardProps> = ({
338338 if ( currentStep > 1 ) {
339339 setCurrentStep ( currentStep - 1 ) ;
340340 // Scroll to top when going back
341- window . scrollTo ( { top : 0 , behavior : 'smooth' } ) ;
341+ if ( typeof window . scrollTo === 'function' ) {
342+ window . scrollTo ( { top : 0 , behavior : 'smooth' } ) ;
343+ }
342344 }
343345 } ;
344346
Original file line number Diff line number Diff line change 11import '@testing-library/jest-dom' ;
2+ import { vi } from 'vitest' ;
3+
4+ const localStorageMock = ( ( ) => {
5+ let store : Record < string , string > = { } ;
6+ return {
7+ getItem : vi . fn ( ( key : string ) => store [ key ] || null ) ,
8+ setItem : vi . fn ( ( key : string , value : string ) => {
9+ store [ key ] = value . toString ( ) ;
10+ } ) ,
11+ clear : vi . fn ( ( ) => {
12+ store = { } ;
13+ } ) ,
14+ removeItem : vi . fn ( ( key : string ) => {
15+ delete store [ key ] ;
16+ } ) ,
17+ key : vi . fn ( ( index : number ) => Object . keys ( store ) [ index ] || null ) ,
18+ length : 0 ,
19+ } ;
20+ } ) ( ) ;
21+
22+ vi . stubGlobal ( 'localStorage' , localStorageMock ) ;
23+ if ( typeof window !== 'undefined' ) {
24+ Object . defineProperty ( window , 'localStorage' , {
25+ value : localStorageMock ,
26+ configurable : true ,
27+ writable : true ,
28+ } ) ;
29+ }
30+
You can’t perform that action at this time.
0 commit comments