File tree Expand file tree Collapse file tree 2 files changed +21
-21
lines changed Expand file tree Collapse file tree 2 files changed +21
-21
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
import ReactDOM from 'react-dom' ;
3
3
import App from './App' ;
4
- import * as utils from '../utils/buildEventSource' ;
5
-
6
- const buildEventSourceSpy = jest . spyOn ( utils , 'buildEventSource' ) ;
7
-
8
- buildEventSourceSpy . mockReturnValue ( {
9
- CLOSED : 0 ,
10
- CONNECTING : 0 ,
11
- OPEN : 0 ,
12
- dispatchEvent ( event ) {
13
- return false ;
14
- } ,
15
- onerror : jest . fn ( ) ,
16
- onmessage : jest . fn ( ) ,
17
- onopen : jest . fn ( ) ,
18
- readyState : 0 ,
19
- url : '' ,
20
- withCredentials : false ,
21
- addEventListener : jest . fn ( ) ,
22
- close : jest . fn ( ) ,
23
- removeEventListener : jest . fn ( )
24
- } ) ;
25
4
26
5
it ( 'renders without crashing' , ( ) => {
27
6
const div = document . createElement ( 'div' ) ;
Original file line number Diff line number Diff line change 1
1
import '@testing-library/jest-dom' ;
2
+
3
+ Object . defineProperty ( window , 'EventSource' , {
4
+ writable : true ,
5
+ value : jest . fn ( ) . mockImplementation ( ( ) => ( {
6
+ CLOSED : 0 ,
7
+ CONNECTING : 0 ,
8
+ OPEN : 0 ,
9
+ dispatchEvent ( event ) {
10
+ return false ;
11
+ } ,
12
+ onerror : jest . fn ( ) ,
13
+ onmessage : jest . fn ( ) ,
14
+ onopen : jest . fn ( ) ,
15
+ readyState : 0 ,
16
+ url : '' ,
17
+ withCredentials : false ,
18
+ addEventListener : jest . fn ( ) ,
19
+ close : jest . fn ( ) ,
20
+ removeEventListener : jest . fn ( )
21
+ } ) )
22
+ } ) ;
You can’t perform that action at this time.
0 commit comments