Skip to content

Commit 7b813fd

Browse files
committed
test(app): spyToBeCalledOnceAsync should delegate to general Times
this removes duplicate code in the utility function
1 parent baf7bed commit 7b813fd

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

tests/globals.js

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -117,22 +117,7 @@ global.Utils = {
117117
return result;
118118
},
119119
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-
clearInterval(interval);
131-
resolve();
132-
}
133-
}, 25);
134-
135-
return promise;
120+
return this.spyToBeCalledTimesAsync(spy, 1, timeout);
136121
},
137122
spyToBeCalledTimesAsync(spy, times = 2, timeout = 5000) {
138123
let interval;

0 commit comments

Comments
 (0)