Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README to reflect Ember 3.x test API #77

Open
jacobq opened this issue Feb 19, 2018 · 2 comments
Open

Update README to reflect Ember 3.x test API #77

jacobq opened this issue Feb 19, 2018 · 2 comments

Comments

@jacobq
Copy link

jacobq commented Feb 19, 2018

I think the Overriding route-action for integration tests section of the README.md file might need to be updated because this.container appears to undefined inside of module --> hooks (Ember v3.0.0, Ember Data v3.0.1, jQuery v3.3.1). Instead, I found that using this.owner.__registry__ or this.owner.__container__.registry seems to work.

@knownasilya
Copy link
Contributor

knownasilya commented Jun 22, 2018

I created this helper:

import { helper } from '@ember/component/helper';

export default function overrideRouteActionsHelper(hooks, actions) {
  hooks.beforeEach(function () {
    this.owner.__registry__
      .registrations['helper:route-action'] = helper((arg) => {
        return this.routeActions[arg];
      });

    this.routeActions = actions;
  });
}

Use like so:

import overrideRouteActions from '../../../helpers/override-route-actions';

module('Integration | Component | table-mapping', function (hooks) {
  setupRenderingTest(hooks);
  overrideRouteActions(hooks, {
    matchBy() {}
  });
 //...
});

Where {{route-action 'matchBy'}} is in my component.

@knownasilya
Copy link
Contributor

I could submit a PR if this is a good solution, and it could just be imported from this addon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants