If spec succeeds, clear the timeout

Prior to this change, the `console.error` statement _always_ ran, 
regardless of whether the promise resolved successfully. With this 
change, we clear the timeout in the scenario where the promise resolves 
successfully.

Co-Authored-By: Antonio Scandurra <as-cii@github.com>
This commit is contained in:
Jason Rudolph
2019-06-13 11:23:30 -04:00
parent f9405cb25d
commit c7d17f6233

View File

@@ -1059,11 +1059,13 @@ describe('Project', () => {
const waitForEvents = paths => {
const remaining = new Set(paths.map(p => fs.realpathSync(p)));
return new Promise((resolve, reject) => {
let expireTimeoutId;
checkCallback = () => {
for (let event of events) {
remaining.delete(event.path);
}
if (remaining.size === 0) {
clearTimeout(expireTimeoutId)
resolve();
}
};
@@ -1076,8 +1078,8 @@ describe('Project', () => {
);
};
expireTimeoutId = setTimeout(expire, 2000);
checkCallback();
setTimeout(expire, 2000);
});
};