How to use the @ember/test-helpers.settled function in @ember/test-helpers

To help you get started, we’ve selected a few @ember/test-helpers 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 CenterForOpenScience / ember-osf-web / tests / helpers / index.ts View on Github external
export async function visit(url: string) {
    try {
        await _visit(url);
    } catch (e) {
        if (e.message !== 'TransitionAborted') {
            throw e;
        }

        // Set this.element for application tests as the original
        // visit's attempt to do so was interupted by an exception
        const context: any = getContext();
        context.element = document.querySelector('#ember-testing');
    }

    await settled();
}
github cibernox / ember-power-select / addon-test-support / index.js View on Github external
async function openIfClosedAndGetContentId(trigger) {
  let contentId = trigger.attributes['aria-owns'] && `${trigger.attributes['aria-owns'].value}`;
  let content = contentId ? document.querySelector(`#${contentId}`) : undefined;
  // If the dropdown is closed, open it
  if (!content || content.classList.contains('ember-basic-dropdown-content-placeholder')) {
    await click(trigger);
    await settled();
    contentId = `${trigger.attributes['aria-owns'].value}`;
  }
  return contentId;
}
github fossasia / open-event-frontend / tests / helpers / custom-helpers.js View on Github external
export async function login(assert, email = null, password = null, gotoLoginPage = true) {
  if (gotoLoginPage) {
    await visit('/login');
  }
  assert.equal(currentURL(), '/login');
  await fillIn('input[name=email]', email !== null ? email : 'opev-fe@test.com');
  await fillIn('input[name=password]', password !== null ? password : 'test-fe-user');
  await click('button[type=submit]');
  await settled();
}
github ember-redux / ember-redux / tests / helpers / ajax.js View on Github external
const patchAjax = function patchAjax(url, method, status, response, responseTime) {
  run(function() {
    unhandled[url] = {response: response, responseTime: responseTime};
  });

  return settled();
}
github topaxi / ember-service-worker-update-notify / addon-test-support / updater.js View on Github external
export async function serviceWorkerUpdate() {
  window.__hasServiceWorkerUpdate__deferred &&
  window.__hasServiceWorkerUpdate__deferred.resolve &&
  window.__hasServiceWorkerUpdate__deferred.resolve(true)

  return await settled();
}
github miragejs / ember-cli-mirage / addon-test-support / setup-mirage.js View on Github external
hooks.afterEach(function() {
    return settled().then(() => {
      if (this.server) {
        this.server.shutdown();
        delete this.server;
      }
    });
  });
}
github cibernox / ember-power-select / addon-test-support / index.js View on Github external
}
  if (potentialTargets.length > 1) {
    let filteredTargets = [].slice.apply(potentialTargets).filter((t) => t.textContent.trim() === valueOrSelector);
    if (optionIndex === undefined) {
      target = filteredTargets[0] || potentialTargets[0];
    } else {
      target = filteredTargets[optionIndex] || potentialTargets[optionIndex];
    }
  } else {
    target = potentialTargets[0];
  }
  if (!target) {
    throw new Error(`You called "selectChoose('${cssPathOrTrigger}', '${valueOrSelector}')" but "${valueOrSelector}" didn't match any option`);
  }
  await click(target);
  return settled();
}
github cibernox / ember-power-calendar / addon-test-support / index.js View on Github external
export async function calendarCenter(selector, newCenter) {
  assert('`calendarCenter` expect a Date object as second argument', newCenter instanceof Date);
  let calendarComponent = findComponentInstance(selector);
  let onCenterChange = calendarComponent.get('onCenterChange');
  assert('You cannot call `calendarCenter` on a component that doesn\'t has an `@onCenterChange` action', !!onCenterChange);
  let publicAPI = calendarComponent.get('publicAPI');
  await run(() => publicAPI.actions.changeCenter(newCenter, publicAPI));
  return settled();
}
github kaliber5 / ember-drag-sort / addon / utils / trigger.js View on Github external
await trigger(sourceItem, 'dragstart')
    await trigger(targetList, 'dragenter')
    await trigger(targetItem, 'dragover', above)
    await trigger(sourceItem, 'dragend')
  } else {
    assert(
      `target list is empty, the only available target index is 0, but target index ${targetIndex} was provided`,
      !targetIndex
    )

    await trigger(sourceItem, 'dragstart')
    await trigger(targetList, 'dragenter')
    await trigger(sourceItem, 'dragend')
  }

  return settled()
}