File tree 1 file changed +14
-10
lines changed
1 file changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -119,19 +119,23 @@ describe('Mocking aborts', () => {
119
119
} ) ;
120
120
121
121
it ( 'throws when passed an already aborted abort signal in the request init' , ( ) => {
122
- const c = new AbortController ( ) ;
123
- c . abort ( ) ;
124
- expect ( ( ) => fetch ( '/' , { signal : c . signal } ) ) . toThrow ( expect . any ( DOMException ) ) ;
122
+ if ( typeof AbortController !== 'undefined' ) {
123
+ const c = new AbortController ( ) ;
124
+ c . abort ( ) ;
125
+ expect ( ( ) => fetch ( '/' , { signal : c . signal } ) ) . toThrow ( expect . any ( DOMException ) ) ;
126
+ }
125
127
} ) ;
126
128
127
129
it ( 'rejects when aborted before resolved' , async ( ) => {
128
- const c = new AbortController ( ) ;
129
- fetch . mockResponse ( async ( ) => {
130
- vi . advanceTimersByTime ( 60 ) ;
131
- return '' ;
132
- } ) ;
133
- setTimeout ( ( ) => c . abort ( ) , 50 ) ;
134
- await expect ( fetch ( '/' , { signal : c . signal } ) ) . rejects . toThrow ( expect . any ( DOMException ) ) ;
130
+ if ( typeof AbortController !== 'undefined' ) {
131
+ const c = new AbortController ( ) ;
132
+ fetch . mockResponse ( async ( ) => {
133
+ vi . advanceTimersByTime ( 60 ) ;
134
+ return '' ;
135
+ } ) ;
136
+ setTimeout ( ( ) => c . abort ( ) , 50 ) ;
137
+ await expect ( fetch ( '/' , { signal : c . signal } ) ) . rejects . toThrow ( expect . any ( DOMException ) ) ;
138
+ }
135
139
} ) ;
136
140
} ) ;
137
141
You can’t perform that action at this time.
0 commit comments