mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
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:
@@ -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);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user