@@ -15,8 +15,10 @@ conditionalTest({ min: 12 })('async_hooks', () => {
15
15
} ) ;
16
16
17
17
test ( 'without strategy hubs should be equal' , ( ) => {
18
- runWithAsyncContext ( hub1 => {
19
- runWithAsyncContext ( hub2 => {
18
+ runWithAsyncContext ( ( ) => {
19
+ const hub1 = getCurrentHub ( ) ;
20
+ runWithAsyncContext ( ( ) => {
21
+ const hub2 = getCurrentHub ( ) ;
20
22
expect ( hub1 ) . toBe ( hub2 ) ;
21
23
} ) ;
22
24
} ) ;
@@ -28,13 +30,15 @@ conditionalTest({ min: 12 })('async_hooks', () => {
28
30
const globalHub = getCurrentHub ( ) ;
29
31
globalHub . setExtra ( 'a' , 'b' ) ;
30
32
31
- runWithAsyncContext ( hub1 => {
33
+ runWithAsyncContext ( ( ) => {
34
+ const hub1 = getCurrentHub ( ) ;
32
35
expect ( hub1 ) . toEqual ( globalHub ) ;
33
36
34
37
hub1 . setExtra ( 'c' , 'd' ) ;
35
38
expect ( hub1 ) . not . toEqual ( globalHub ) ;
36
39
37
- runWithAsyncContext ( hub2 => {
40
+ runWithAsyncContext ( ( ) => {
41
+ const hub2 = getCurrentHub ( ) ;
38
42
expect ( hub2 ) . toEqual ( hub1 ) ;
39
43
expect ( hub2 ) . not . toEqual ( globalHub ) ;
40
44
@@ -59,13 +63,15 @@ conditionalTest({ min: 12 })('async_hooks', () => {
59
63
const globalHub = getCurrentHub ( ) ;
60
64
await addRandomExtra ( globalHub , 'a' ) ;
61
65
62
- await runWithAsyncContext ( async hub1 => {
66
+ await runWithAsyncContext ( async ( ) => {
67
+ const hub1 = getCurrentHub ( ) ;
63
68
expect ( hub1 ) . toEqual ( globalHub ) ;
64
69
65
70
await addRandomExtra ( hub1 , 'b' ) ;
66
71
expect ( hub1 ) . not . toEqual ( globalHub ) ;
67
72
68
- await runWithAsyncContext ( async hub2 => {
73
+ await runWithAsyncContext ( async ( ) => {
74
+ const hub2 = getCurrentHub ( ) ;
69
75
expect ( hub2 ) . toEqual ( hub1 ) ;
70
76
expect ( hub2 ) . not . toEqual ( globalHub ) ;
71
77
@@ -78,16 +84,19 @@ conditionalTest({ min: 12 })('async_hooks', () => {
78
84
test ( 'context single instance' , ( ) => {
79
85
setHooksAsyncContextStrategy ( ) ;
80
86
81
- runWithAsyncContext ( hub => {
82
- expect ( hub ) . toBe ( getCurrentHub ( ) ) ;
87
+ const globalHub = getCurrentHub ( ) ;
88
+ runWithAsyncContext ( ( ) => {
89
+ expect ( globalHub ) . not . toBe ( getCurrentHub ( ) ) ;
83
90
} ) ;
84
91
} ) ;
85
92
86
93
test ( 'context within a context not reused' , ( ) => {
87
94
setHooksAsyncContextStrategy ( ) ;
88
95
89
- runWithAsyncContext ( hub1 => {
90
- runWithAsyncContext ( hub2 => {
96
+ runWithAsyncContext ( ( ) => {
97
+ const hub1 = getCurrentHub ( ) ;
98
+ runWithAsyncContext ( ( ) => {
99
+ const hub2 = getCurrentHub ( ) ;
91
100
expect ( hub1 ) . not . toBe ( hub2 ) ;
92
101
} ) ;
93
102
} ) ;
@@ -96,9 +105,11 @@ conditionalTest({ min: 12 })('async_hooks', () => {
96
105
test ( 'context within a context reused when requested' , ( ) => {
97
106
setHooksAsyncContextStrategy ( ) ;
98
107
99
- runWithAsyncContext ( hub1 => {
108
+ runWithAsyncContext ( ( ) => {
109
+ const hub1 = getCurrentHub ( ) ;
100
110
runWithAsyncContext (
101
- hub2 => {
111
+ ( ) => {
112
+ const hub2 = getCurrentHub ( ) ;
102
113
expect ( hub1 ) . toBe ( hub2 ) ;
103
114
} ,
104
115
{ reuseExisting : true } ,
@@ -112,7 +123,8 @@ conditionalTest({ min: 12 })('async_hooks', () => {
112
123
let d1done = false ;
113
124
let d2done = false ;
114
125
115
- runWithAsyncContext ( hub => {
126
+ runWithAsyncContext ( ( ) => {
127
+ const hub = getCurrentHub ( ) ;
116
128
hub . getStack ( ) . push ( { client : 'process' } as any ) ;
117
129
expect ( hub . getStack ( ) [ 1 ] ) . toEqual ( { client : 'process' } ) ;
118
130
// Just in case so we don't have to worry which one finishes first
@@ -125,7 +137,8 @@ conditionalTest({ min: 12 })('async_hooks', () => {
125
137
} ) ;
126
138
} ) ;
127
139
128
- runWithAsyncContext ( hub => {
140
+ runWithAsyncContext ( ( ) => {
141
+ const hub = getCurrentHub ( ) ;
129
142
hub . getStack ( ) . push ( { client : 'local' } as any ) ;
130
143
expect ( hub . getStack ( ) [ 1 ] ) . toEqual ( { client : 'local' } ) ;
131
144
setTimeout ( ( ) => {
0 commit comments