We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
spyToBeCalledOnceAsync
Times
1 parent baf7bed commit 7b813fdCopy full SHA for 7b813fd
tests/globals.js
@@ -117,22 +117,7 @@ global.Utils = {
117
return result;
118
},
119
spyToBeCalledOnceAsync(spy, timeout = 5000) {
120
- let interval;
121
- const { resolve, reject, promise } = Promise.defer();
122
- const timer = setTimeout(() => {
123
- clearInterval(interval);
124
- reject(new Error('Spy was not called within timeout period.'));
125
- }, timeout);
126
-
127
- interval = setInterval(() => {
128
- if (spy.callCount > 0) {
129
- clearTimeout(timer);
130
131
- resolve();
132
- }
133
- }, 25);
134
135
- return promise;
+ return this.spyToBeCalledTimesAsync(spy, 1, timeout);
136
137
spyToBeCalledTimesAsync(spy, times = 2, timeout = 5000) {
138
let interval;
0 commit comments