ember-codemods / ember-mocha-codemods

Codemod scripts for ember-mocha
MIT License
4 stars 6 forks source link

this.subject => this.owner.lookup #107

Closed jbryson3 closed 4 years ago

jbryson3 commented 4 years ago

Is there a codemod that currently handles transitioning this.subject() syntax to this.owner.lookup() syntax? I believe I saw one in the ember-qunit-codemods repo that did something like that.

Example Before

setupTest('export:audience-definitions', {
  needs: ['service:retry']
});
//...
let subject = this.subject({ analysis: zeroAudienceAnalysis });

Example After

setupTest();
//...
let subject = this.owner.lookup('export:audience-definitions');
subject.set('analysis', zeroAudienceAnalysis);
pangratz commented 4 years ago

The one linked to in https://github.com/ember-codemods/ember-mocha-codemods#testing-api-beginning-in-014 should cover this, so basically via https://github.com/ember-codemods/ember-mocha-codemods/blob/90451be10db7fcf5ad7f927d2a5feee413f74e7d/fourteen-testing-api.js#L444

jbryson3 commented 4 years ago

Thanks!