testLoadWhenPreloading() {
    const mm = getModuleManager({'a': [], 'b': [], 'c': []});
    mm.setLoader(createSuccessfulNonBatchLoader(mm));

    const origBeforeLoadModuleCode = mm.beforeLoadModuleCode;
    const origSetLoaded = mm.setLoaded;
    const calls = [0, 0];
    mm.beforeLoadModuleCode = (id) => {
      calls[0]++;
      origBeforeLoadModuleCode.call(mm, id);
    };
    mm.setLoaded = () => {
      calls[1]++;
      origSetLoaded.call(mm);
    };

    let calledBack = false;
    let error = null;

    mm.preloadModule('c', 2);
    assertFalse(
        'module "c" should not be loading yet', mm.isModuleLoading('c'));
    clock.tick(2);
    assertTrue('module "c" should now be loading', mm.isModuleLoading('c'));

    const d = mm.load('c');
    d.then(
        (ctx) => {
          calledBack = true;
        },
        (err) => {
          error = err;
        });

    assertTrue('module "c" should still be loading', mm.isModuleLoading('c'));
    clock.tick(5);
    assertFalse('module "c" should be done loading', mm.isModuleLoading('c'));
    assertEquals('beforeLoad should only be called once for "c"', 1, calls[0]);
    assertEquals('setLoaded should only be called once for "c"', 1, calls[1]);

    assertTrue(calledBack);
    assertNull(error);
  }
Tests that load doesn't trigger another load if a module is already
preloading.