File tree 1 file changed +13
-2
lines changed
1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 1
- export default typeof AbortController === "undefined" ? mockit : it ;
1
+ export default typeof AbortController === "undefined" || typeof performance === "undefined" ? mockit : it ;
2
2
3
3
function mockit ( description , run ) {
4
4
return it ( description , withMock ( run ) ) ;
@@ -13,18 +13,29 @@ mockit.only = (description, run) => {
13
13
} ;
14
14
15
15
class MockAbortController {
16
+ constructor ( ) {
17
+ this . signal = { aborted : false } ;
18
+ }
16
19
abort ( ) {
17
- // mock noop for node 14
20
+ this . signal . aborted = true ;
21
+ }
22
+ }
23
+
24
+ class MockPerformance {
25
+ static now ( ) {
26
+ return Date . now ( ) ;
18
27
}
19
28
}
20
29
21
30
function withMock ( run ) {
22
31
return async ( ) => {
23
32
global . AbortController = MockAbortController ;
33
+ global . performance = MockPerformance ;
24
34
try {
25
35
return await run ( ) ;
26
36
} finally {
27
37
delete global . AbortController ;
38
+ delete global . performance ;
28
39
}
29
40
} ;
30
41
}
You can’t perform that action at this time.
0 commit comments