How to use the ember-concurrency/-task-instance.wrap function in ember-concurrency

To help you get started, we’ve selected a few ember-concurrency 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 machty / ember-concurrency / tests / helpers / generator-tests.js View on Github external
}
      }

      yield rawTimeout(15);
    }
  }
});

const HELPER_METHODS = {
  find(...args) {
    return find(this.application, ...args);
  },
  visit(...args) {
    return visit(...args);
  },
  click: wrap(function * (selector) {
    yield find(this.application, selector);
    return click(selector);
  }),
};

function test(description, fn) {
  qunitTest(description, function(assert) {
    Object.assign(this, HELPER_METHODS);
    window.QUnit.config.current._isTaskTest = true;
    let qunitDone = assert.async();
    let done = () => {
      run.backburner.cancelTimers();
      qunitDone();
    };
    if (fn.constructor.name === 'GeneratorFunction') {
      go([assert], fn, {
github machty / ember-concurrency / tests / helpers / generator-tests.js View on Github external
import { resolve } from 'rsvp';
import { test as qunitTest } from 'ember-qunit';
import { wrap, go } from 'ember-concurrency/-task-instance';
import { run } from "@ember/runloop";
import { visit, click, settled, findAll } from '@ember/test-helpers';
import {
  raw,
  rawTimeout
} from 'ember-concurrency/utils';

const find = wrap(function * (app, selector, options = {}) {
  let startedAt = + new Date();
  let timeoutMs = options.timeout;
  let count = typeof options.count === 'undefined' ? 1 : options.count;

  let isSettled = false;
  settled().then(() => {
    isSettled = true;
  });

  while(true) {
    let els = findAll(selector);

    if (els.length === count) {
      return raw([...els]);
    } else {
      if (timeoutMs) {