Skip to content

Commit 150460e

Browse files
committed
add onReadyStateChange
1 parent 46e8819 commit 150460e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

packages/signals/signals/src/core/signal-generators/network-gen/__tests__/network-interceptor.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,19 @@ describe(NetworkInterceptor, () => {
6161
LOADING = 3
6262
DONE = 4
6363

64-
private _emitter = new EventEmitter()
64+
private _emitter: EventEmitter
6565
public readyState = 0
6666
public status = 0
6767
public responseText = ''
68-
public onreadystatechange: (() => void) | null = null
6968
public responseURL = ''
7069
public _responseMethod = ''
7170
public _responseHeaders = ''
71+
public onreadystatechange = () => undefined
72+
constructor() {
73+
this._emitter = new EventEmitter().on('readystatechange', () => {
74+
this.onreadystatechange()
75+
})
76+
}
7277

7378
open(method: string, url: string) {
7479
this._responseMethod = method
@@ -93,9 +98,6 @@ describe(NetworkInterceptor, () => {
9398
this.responseURL = 'http://example.com'
9499
this._responseHeaders = 'Content-Type: application/json'
95100
this._emitter.emit('readystatechange')
96-
if (this.onreadystatechange) {
97-
this.onreadystatechange()
98-
}
99101
}, 40)
100102
}
101103

0 commit comments

Comments
 (0)