This file contains hidden or 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
| // Let's say you have a function that does some async operation inside setTimeout (think of polling for data) | |
| function runInterval(callback, interval = 1000) { | |
| setInterval(async () => { | |
| const results = await Promise.resolve(42) // this might fetch some data from server | |
| callback(results) | |
| }, interval) | |
| } | |
| // Goal: We want to test that function - make sure our callback was called |