static async fakeEventLoop(duration, onTick) {
    // Run this synchronously:
    for (let time = 0; time < duration; time++) {
      // We shouldn't need more than 6 rounds.
      for (let i = 0; i < 6; i++) {
        jasmine.clock().tick(0);
        await Promise.resolve();  // eslint-disable-line no-await-in-loop
      }

      if (onTick) {
        await onTick(time);  // eslint-disable-line no-await-in-loop
      }
      jasmine.clock().tick(1000);
      // eslint-disable-next-line no-await-in-loop
      await Promise.resolve();
    }
  }
Fakes an event loop. Each tick processes some number of instantaneous
operations and advances the simulated clock forward by 1 second. Calls
onTick just before each tick if it's specified.

@param {number} duration The number of seconds of simulated time.
@param {function(number)=} onTick