Skip to content

Commit

Permalink
Merge pull request #19542 from anehx/fix-initializer-test-blueprints
Browse files Browse the repository at this point in the history
[BUGFIX beta] pass module prefix to initializer test blueprints
  • Loading branch information
rwjblue authored May 24, 2021
2 parents 66ea56f + c69365b commit 6d6d43f
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
import Application from '@ember/application';

import config from '<%= modulePrefix %>/config/environment';
import { initialize } from '<%= modulePrefix %>/initializers/<%= dasherizedModuleName %>';
import { module, test } from 'qunit';
import Resolver from 'ember-resolver';
<% if (destroyAppExists) { %>import destroyApp from '../../helpers/destroy-app';<% } else { %>import { run } from '@ember/runloop';<% } %>

module('<%= friendlyTestName %>', function(hooks) {
hooks.beforeEach(function() {
this.TestApplication = class TestApplication extends Application {}
module('<%= friendlyTestName %>', function (hooks) {
hooks.beforeEach(function () {
this.TestApplication = class TestApplication extends Application {
modulePrefix = config.modulePrefix;
podModulePrefix = config.podModulePrefix;
Resolver = Resolver;
};
this.TestApplication.initializer({
name: 'initializer under test',
initialize
initialize,
});

this.application = this.TestApplication.create({ autoboot: false, Resolver });
this.application = this.TestApplication.create({ autoboot: false });
});

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

// TODO: Replace this with your real tests.
test('it works', async function(assert) {
test('it works', async function (assert) {
await this.application.boot();

assert.ok(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
import Application from '@ember/application';

import config from '<%= modulePrefix %>/config/environment';
import { initialize } from '<%= modulePrefix %>/instance-initializers/<%= dasherizedModuleName %>';
import { module, test } from 'qunit';
import Resolver from 'ember-resolver';
<% if (destroyAppExists) { %>import destroyApp from '../../helpers/destroy-app';<% } else { %>import { run } from '@ember/runloop';<% } %>

module('<%= friendlyTestName %>', function(hooks) {
hooks.beforeEach(function() {
this.TestApplication = class TestApplication extends Application {}
module('<%= friendlyTestName %>', function (hooks) {
hooks.beforeEach(function () {
this.TestApplication = class TestApplication extends Application {
modulePrefix = config.modulePrefix;
podModulePrefix = config.podModulePrefix;
Resolver = Resolver;
};
this.TestApplication.instanceInitializer({
name: 'initializer under test',
initialize
initialize,
});
this.application = this.TestApplication.create({ autoboot: false, Resolver });
this.application = this.TestApplication.create({ autoboot: false });
this.instance = this.application.buildInstance();
});
hooks.afterEach(function() {
hooks.afterEach(function () {
<% if (destroyAppExists) { %>destroyApp(this.instance);<% } else { %>run(this.instance, 'destroy');<% } %>
<% if (destroyAppExists) { %>destroyApp(this.application);<% } else { %>run(this.application, 'destroy');<% } %>
});

// TODO: Replace this with your real tests.
test('it works', async function(assert) {
test('it works', async function (assert) {
await this.instance.boot();

assert.ok(true);
Expand Down
19 changes: 12 additions & 7 deletions node-tests/fixtures/initializer-test/rfc232.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
import Application from '@ember/application';

import config from 'my-app/config/environment';
import { initialize } from 'my-app/initializers/foo';
import { module, test } from 'qunit';
import Resolver from 'ember-resolver';
import { run } from '@ember/runloop';

module('Unit | Initializer | foo', function(hooks) {
hooks.beforeEach(function() {
this.TestApplication = class TestApplication extends Application {}
module('Unit | Initializer | foo', function (hooks) {
hooks.beforeEach(function () {
this.TestApplication = class TestApplication extends Application {
modulePrefix = config.modulePrefix;
podModulePrefix = config.podModulePrefix;
Resolver = Resolver;
};
this.TestApplication.initializer({
name: 'initializer under test',
initialize
initialize,
});

this.application = this.TestApplication.create({ autoboot: false, Resolver });
this.application = this.TestApplication.create({ autoboot: false });
});

hooks.afterEach(function() {
hooks.afterEach(function () {
run(this.application, 'destroy');
});

// TODO: Replace this with your real tests.
test('it works', async function(assert) {
test('it works', async function (assert) {
await this.application.boot();

assert.ok(true);
Expand Down
19 changes: 12 additions & 7 deletions node-tests/fixtures/instance-initializer-test/rfc232.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
import Application from '@ember/application';

import config from 'my-app/config/environment';
import { initialize } from 'my-app/instance-initializers/foo';
import { module, test } from 'qunit';
import Resolver from 'ember-resolver';
import { run } from '@ember/runloop';

module('Unit | Instance Initializer | foo', function(hooks) {
hooks.beforeEach(function() {
this.TestApplication = class TestApplication extends Application {}
module('Unit | Instance Initializer | foo', function (hooks) {
hooks.beforeEach(function () {
this.TestApplication = class TestApplication extends Application {
modulePrefix = config.modulePrefix;
podModulePrefix = config.podModulePrefix;
Resolver = Resolver;
};
this.TestApplication.instanceInitializer({
name: 'initializer under test',
initialize
initialize,
});
this.application = this.TestApplication.create({ autoboot: false, Resolver });
this.application = this.TestApplication.create({ autoboot: false });
this.instance = this.application.buildInstance();
});
hooks.afterEach(function() {
hooks.afterEach(function () {
run(this.instance, 'destroy');
run(this.application, 'destroy');
});

// TODO: Replace this with your real tests.
test('it works', async function(assert) {
test('it works', async function (assert) {
await this.instance.boot();

assert.ok(true);
Expand Down

0 comments on commit 6d6d43f

Please sign in to comment.