Skip to content

Commit

Permalink
[BUGFIX] Fix initialiters tests blueprints
Browse files Browse the repository at this point in the history
  • Loading branch information
Serabe committed Mar 9, 2018
1 parent a28755d commit dc63a24
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Application from '@ember/application';
import { initialize } from '<%= dasherizedModulePrefix %>/initializers/<%= dasherizedModuleName %>';
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
import destroyApp from '../../helpers/destroy-app';
<% if (destroyAppExists) { %>import destroyApp from '../../helpers/destroy-app';<% } else { %>import { run } from '@ember/runloop';<% } %>

module('<%= friendlyTestName %>', function(hooks) {
setupTest(hooks);
Expand All @@ -19,7 +19,7 @@ module('<%= friendlyTestName %>', function(hooks) {
});

hooks.afterEach(function() {
destroyApp(this.application);
<% if (destroyAppExists) { %>destroyApp(this.application);<% } else { %>run(this.application, 'destroy');<% } %>
});

// Replace this with your real tests.
Expand Down
5 changes: 4 additions & 1 deletion blueprints/instance-initializer-test/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

const path = require('path');
const existsSync = require('exists-sync');
const stringUtils = require('ember-cli-string-utils');

const useTestFrameworkDetector = require('../test-framework-detector');
Expand All @@ -9,7 +11,8 @@ module.exports = useTestFrameworkDetector({
locals: function(options) {
return {
friendlyTestName: ['Unit', 'Instance Initializer', options.entity.name].join(' | '),
dasherizedModulePrefix: stringUtils.dasherize(options.project.config().modulePrefix)
dasherizedModulePrefix: stringUtils.dasherize(options.project.config().modulePrefix),
destroyAppExists: existsSync(path.join(this.project.root, '/tests/helpers/destroy-app.js'))
};
}
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Application from '@ember/application';
import { run } from '@ember/runloop';
import { initialize } from '<%= dasherizedModulePrefix %>/instance-initializers/<%= dasherizedModuleName %>';
import { module, test } from 'qunit';
import destroyApp from '../../helpers/destroy-app';
import { module, test } from 'qunit';<% if (destroyAppExists) { %>
import destroyApp from '../../helpers/destroy-app';<% } %>

module('<%= friendlyTestName %>', {
beforeEach() {
Expand All @@ -13,7 +13,7 @@ module('<%= friendlyTestName %>', {
},
afterEach() {
run(this.appInstance, 'destroy');
destroyApp(this.application);
<% if (destroyAppExists) { %>destroyApp(this.application);<% } else { %>run(this.application, 'destroy');<% } %>
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Application from '@ember/application';
import { initialize } from '<%= dasherizedModulePrefix %>/instance-initializers/<%= dasherizedModuleName %>';
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
import destroyApp from '../../helpers/destroy-app';
<% if (destroyAppExists) { %>import destroyApp from '../../helpers/destroy-app';<% } else { %>import { run } from '@ember/runloop';<% } %>

module('<%= friendlyTestName %>', function(hooks) {
setupTest(hooks);
Expand All @@ -18,8 +18,8 @@ module('<%= friendlyTestName %>', function(hooks) {
this.instance = this.application.buildInstance();
});
hooks.afterEach(function() {
destroyApp(this.application);
destroyApp(this.instance);
<% if (destroyAppExists) { %>destroyApp(this.application);<% } else { %>run(this.application, 'destroy');<% } %>
<% if (destroyAppExists) { %>destroyApp(this.instance);<% } else { %>run(this.instance, 'destroy');<% } %>
});

// Replace this with your real tests.
Expand Down

0 comments on commit dc63a24

Please sign in to comment.