How to use the bluebird.delay function in bluebird

To help you get started, we’ve selected a few bluebird examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github appium / appium-android-driver / test / functional / commands / keyboard / keyboard-e2e-specs.js View on Github external
async function clearKeyEvents (driver) {
  let el = await getElement(driver, BUTTON_CLASS);
  driver.click(el);

  // wait a moment for the clearing to occur, lest we too quickly try to enter more text
  await B.delay(500);
}
github selsamman / amorphic / test / postgres / amorphic.js View on Github external
// and semotus tries to send back a sync: false messages to force the client to refresh we handle
                // it ourselves and end the test.  Note that for whaever reason the implementation of XMLHTTPRequest
                // used here doesn not handle overlapping calls properly.  It will send the second call but will
                // never see the response for the inner call.  For this reason the full reset sequence never happens.
                var ServerRemoteObjectTemplate = serverController.__template__.objectTemplate;
                var oldSendMessage = ServerRemoteObjectTemplate._getSession().sendMessage;
                ServerRemoteObjectTemplate._getSession().sendMessage =  function (message) {
                    oldSendMessage.call(ServerRemoteObjectTemplate, message);
                    expect(message.sync).to.equal(false);
                    expect((new Date()).getTime() > (startTime + 5000));
                    done();
                };
            }).catch(function(e) {
                done(e);
            });
        Bluebird.delay(100).then(function () {
            RemoteObjectTemplate._getSession().sendMessageEnabled = true; // Force duplicate message
            clientController.mainFunc()
                .then(function () {
                    expect('Should not be here').to.equal(false);
                }, function (e) {
                    expect('Should not be here').to.equal(false);
                }).catch(function(e) {
                    done(e);
                });
        });
    });
github appium / appium-desktop / app / renderer / components / Inspector / Screenshot.js View on Github external
/**
     * This is way to select overlapped behind views of Screenshot component
     */
    if (screenshotInteractionMode === SELECT) {
      this.clickScreenshotElement(e.clientX, e.clientY);
    } else if (screenshotInteractionMode === TAP) {
      applyClientMethod({
        methodName: 'tap',
        args: [x, y],
      });
    } else if (screenshotInteractionMode === SWIPE) {
      if (!swipeStart) {
        setSwipeStart(x, y);
      } else if (!swipeEnd) {
        setSwipeEnd(x, y);
        await B.delay(500); // Wait a second to do the swipe so user can see the SVG line
        await this.handleDoSwipe();
      }
    }
  }
github appium / appium-desktop / app / main / auto-updater.js View on Github external
async checkForUpdates () {
    const isWin = process.platform === 'win32';
    const isMac = process.platform === 'darwin';
    const SQUIRREL_FIRST_RUN = 'SQUIRREL_FIRST_RUN';

    // Only check for updates on Mac and Windows (auto update not supported in linux)
    if (isMac || isWin) {
      log.info('Checking for updates');

      // squirrel.windows needs time to initialize the first time it's run (https://github.com/electron/electron/issues/4306)
      // if it's a first run, give it a long time (20 seconds) to let squirrel.windows initialize before checking for updates
      if (isWin && !await settings.get(SQUIRREL_FIRST_RUN)) {
        await B.delay(20000);
        await settings.set(SQUIRREL_FIRST_RUN, true);
      }
      this.setState({
        isCheckingForUpdates: true,
      });
      autoUpdater.checkForUpdates();
    } else {
      this.setState({
        unsupported: true,
      });
    }
  }
github elastic / kibana / src / server / plugins / elasticsearch / lib / health_check.js View on Github external
.then(function (resp) {
      // if "timed_out" === true then elasticsearch could not
      // find any idices matching our filter within 5 seconds
      if (resp.timed_out) {
        plugin.status.yellow('No existing Kibana index found');
        return createKibanaIndex(server);
      }

      // If status === "red" that means that index(es) were found
      // but the shards are not ready for queries
      if (resp.status === 'red') {
        plugin.status.red('Elasticsearch is still initializing the kibana index... Trying again in 2.5 second.');
        return Promise.delay(2500).then(waitForShards);
      }

      // otherwise we are g2g
      plugin.status.green('Kibana index ready');
    });
  }
github yortus / asyncawait / test / await.js View on Github external
        var bar = async(function () { return await(Promise.delay(20).then(function () { throw new Error('bar'); })); });
        var all = async(function () { return await([foo(), bar()]); });
github appium / appium-ios-driver / test / e2e / testapp / timeout / short-timeout-specs.js View on Github external
it('should die with short command timeout', async function () {
      await driver.timeouts('command', 3000);
      await B.delay(5500);
      await B.resolve(driver.findElement('accessibility id', 'dont exist dogg'))
        .catch(throwMatchableError)
        .should.be.rejectedWith(/jsonwpCode: (13|6)/);
    });
  });
github fullcube / loopback-component-fsm / test / fullcube-state-machine / common / models / order.js View on Github external
Order.observe('fsm:ondeliver', ctx => {
    log.info(`Delivering order ${ctx.instance.id}`)
    return Promise.delay(100)
  })
  Order.observe('fsm:onentereddelivered', ctx => {
github IndigoUnited / node-planify / test / functional.js View on Github external
            .step('step 4', { slow: 500 }, () => { return Promise.delay(10); })
            .run({ reporter })
github 0xTracker / 0x-tracker-worker / src / jobs / resolve-tokens.js View on Github external
await bluebird.mapSeries(unresolvedTokens, async token => {
    const { address } = token;
    const resolvedToken = await getTokenInfo(address);

    if (resolvedToken === null) {
      logger.warn(`no token info found for ${address}`);
      await bluebird.delay(3000);
      return;
    }

    const tokenDetails = _.pick(resolvedToken, [
      'address',
      'decimals',
      'name',
      'symbol',
    ]);

    await withTransaction(async session => {
      await Token.updateOne(
        { address },
        { $set: { ...tokenDetails, resolved: true } },
        { session },
      );