-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(deps): update dependency sinon to v19 (#5028)
* chore(deps): update dependency sinon to v19 * Fix sinon test based on breaking changes in fake timers. * update fake timers in jasmine --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Nico Jansen <jansennico@gmail.com>
- Loading branch information
1 parent
88caf82
commit 099a031
Showing
6 changed files
with
87 additions
and
52 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,25 @@ | ||
import { promisify } from 'util'; | ||
import type Sinon from 'sinon'; | ||
|
||
/** | ||
* Wait `n` ticks. This allows async tasks to progress. | ||
* @param n The number of ticks to wait | ||
*/ | ||
export async function tick(n = 1): Promise<void> { | ||
const nextTickAsPromised = promisify(process.nextTick); | ||
|
||
for await (const _ of Array.from({ length: n })) { | ||
await nextTickAsPromised(); | ||
for (let i = 0; i < n; i++) { | ||
await nextTick(); | ||
} | ||
} | ||
|
||
export function createFakeTick(clock: Sinon.SinonFakeTimers) { | ||
return async function fakeTick(n = 1) { | ||
const onGoingTick = tick(n); | ||
clock.tick(n); | ||
await onGoingTick; | ||
}; | ||
} | ||
|
||
function nextTick() { | ||
return new Promise<void>((resolve) => { | ||
process.nextTick(() => resolve()); | ||
}); | ||
} |