How to use the @ember/test-helpers.getContext 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 miragejs / ember-cli-mirage / addon / get-rfc232-test-context.js View on Github external
export default function getRfc232TestContext() {
  // Support older versions of `ember-qunit` that don't have
  // `@ember/test-helpers` (and therefore cannot possibly be running an
  // rfc232/rfc268 test).
  if (require.has('@ember/test-helpers')) {
    let { getContext } = require('@ember/test-helpers');
    return getContext();
  }
}
github cardstack / cardstack / packages / test-support / addon-test-support / test-helpers.js View on Github external
export function getTools() {
  return getContext().owner.lookup('service:cardstack-tools');
}
github cardstack / cardstack / packages / test-support / addon-test-support / test-helpers.js View on Github external
return getSpaceForCard(type, id).then(space => {
    let context = getContext();
    let card = space.get('primaryCard');
    let params = space.get('params');
    context.set('card', card);
    context.set('format', format);
    context.set('params', Object.assign({}, params, options.params || {}));

    if (options.width) {
      context.set('widthStyle', htmlSafe(`width: ${options.width}`));
      return render(hbs`
      <div style="{{widthStyle}}">
        {{cardstack-content content=card format=format params=params }}
      </div>`);
    } else {
      return render(hbs`{{cardstack-content content=card format=format params=params }}`);
    }
  });
github cardstack / cardstack / packages / test-support / addon-test-support / test-helpers.js View on Github external
export function getSpaceForCard(type, id) {
  return getContext()
    .owner.lookup('service:store')
    .findRecord('space', `/${pluralize(type)}/${id}`);
}
github emberjs / ember-test-helpers / addon-test-support / ember-test-helpers / legacy-0-6-x / abstract-test-module.js View on Github external
getContext() {
    if (this.context) {
      return this.context;
    }

    return (this.context = getContext() || {});
  }
github emberjs / ember-mocha / addon-test-support / ember-mocha / setup-test-factory.js View on Github external
return module.setup().then(() => {
        var context = getContext();
        Object.keys(context).forEach(key => {
          this[key] = context[key];
        });
      });
    });
github emberjs / ember-mocha / addon-test-support / ember-mocha / mocha-module.js View on Github external
return module.setup().then(() => {
        var context = getContext();
        Object.keys(context).forEach(key => {
          this[key] = context[key];
        });
      });
    });
github kaliber5 / ember-bootstrap / tests / helpers / contextual-help.js View on Github external
export function assertPositioning(assert, selector = '.tooltip') {
  assert.dom(selector).exists({ count: 1 }, 'Element exists.');

  let rootEl = getContext().element;
  let tooltip = rootEl.querySelector(selector);
  let trigger = rootEl.querySelector('#target');
  let margin = -parseInt(window.getComputedStyle(tooltip).marginTop, 10) + parseInt(window.getComputedStyle(tooltip).marginBottom, 10);
  let tooltipPos = Math.round(offset(tooltip).top + tooltip.offsetHeight + margin);
  let triggerPos = Math.round(offset(trigger).top);
  assert.ok(Math.abs(triggerPos - tooltipPos) &lt;= 1, `Expected position: ${triggerPos}, actual: ${tooltipPos}`);
}
github jkusa / ember-cli-clipboard / addon-test-support / index.js View on Github external
export function triggerCopyError(selector) {
  const { owner } = getContext();
  _fireComponentAction(owner, selector, 'error');
}