ember-codemods / ember-qunit-codemod

MIT License
36 stars 20 forks source link

Handle "options generator" functions for moduleFor* #14

Open rwjblue opened 7 years ago

rwjblue commented 7 years ago

Input:

moduleFor('service:foo', callSomeMethod());

test('stuff here', function(assert) {
  // ...snip...
});

Suggested output:

import { module } from 'qunit';
import { setupTest } from 'ember-qunit';

let options = callSomeMethod();
module('service:foo', function(hooks) {
  setupTest(hooks);

  options.before && hooks.before(options.before);
  options.beforeEach && hooks.beforeEach(options.beforeEach);
  options.afterEach && hooks.afterEach(options.afterEach);
  options.after && hooks.after(options.after);
});

test('stuff here', function(assert) {
  // ...snip...
});
Turbo87 commented 7 years ago

I'd prefer real if conditions

rwjblue commented 7 years ago

Ya, definitely fine with me also.