ember-qunit-codemod icon indicating copy to clipboard operation
ember-qunit-codemod copied to clipboard

Handle "options generator" functions for moduleFor*

Open rwjblue opened this issue 8 years ago • 2 comments

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...
});

rwjblue avatar Oct 21 '17 03:10 rwjblue

I'd prefer real if conditions

Turbo87 avatar Oct 21 '17 08:10 Turbo87

Ya, definitely fine with me also.

rwjblue avatar Oct 21 '17 11:10 rwjblue