diff --git a/blueprints/instance-initializer-test/mocha-rfc-232-files/__root__/__testType__/__path__/__name__-test.js b/blueprints/instance-initializer-test/mocha-rfc-232-files/__root__/__testType__/__path__/__name__-test.js new file mode 100644 index 00000000000..87d2fc6a096 --- /dev/null +++ b/blueprints/instance-initializer-test/mocha-rfc-232-files/__root__/__testType__/__path__/__name__-test.js @@ -0,0 +1,28 @@ +import { expect } from 'chai'; +import { describe, it, beforeEach, afterEach } from 'mocha'; +import Application from '@ember/application'; +import { initialize } from '<%= modulePrefix %>/instance-initializers/<%= dasherizedModuleName %>'; +<% if (destroyAppExists) { %>import destroyApp from '../../helpers/destroy-app';<% } else { %>import { run } from '@ember/runloop';<% } %> + +describe('<%= friendlyTestName %>', function() { + beforeEach(function() { + this.TestApplication = Application.extend(); + this.TestApplication.instanceInitializer({ + name: 'initializer under test', + initialize + }); + this.application = this.TestApplication.create({ autoboot: false }); + this.instance = this.application.buildInstance(); + }); + afterEach(function() { + <% if (destroyAppExists) { %>destroyApp(this.instance);<% } else { %>run(this.instance, 'destroy');<% } %> + <% if (destroyAppExists) { %>destroyApp(this.application);<% } else { %>run(this.application, 'destroy');<% } %> + }); + + // Replace this with your real tests. + it('works', async function() { + await this.instance.boot(); + + expect(true).to.be.ok; + }); +}); diff --git a/node-tests/blueprints/instance-initializer-test-test.js b/node-tests/blueprints/instance-initializer-test-test.js index 33a72808cc9..2f489d86159 100644 --- a/node-tests/blueprints/instance-initializer-test-test.js +++ b/node-tests/blueprints/instance-initializer-test-test.js @@ -75,6 +75,21 @@ describe('Blueprint: instance-initializer-test', function() { }); }); }); + + describe('with ember-mocha@0.14.0', function() { + beforeEach(function() { + modifyPackages([{ name: 'ember-qunit', delete: true }, { name: 'ember-mocha', dev: true }]); + generateFakePackageManifest('ember-mocha', '0.14.0'); + }); + + it('instance-initializer-test foo for mocha', function() { + return emberGenerateDestroy(['instance-initializer-test', 'foo'], _file => { + expect(_file('tests/unit/instance-initializers/foo-test.js')).to.equal( + fixture('instance-initializer-test/mocha-rfc232.js') + ); + }); + }); + }); }); describe('in addon', function() { @@ -160,6 +175,21 @@ describe('Blueprint: instance-initializer-test', function() { }); }); }); + + describe('with ember-mocha@0.14.0', function() { + beforeEach(function() { + modifyPackages([{ name: 'ember-qunit', delete: true }, { name: 'ember-mocha', dev: true }]); + generateFakePackageManifest('ember-mocha', '0.14.0'); + }); + + it('instance-initializer-test foo for mocha', function() { + return emberGenerateDestroy(['instance-initializer-test', 'foo'], _file => { + expect(_file('src/init/instance-initializers/foo-test.js')).to.equal( + fixture('instance-initializer-test/module-unification/mocha-rfc232.js') + ); + }); + }); + }); }); describe('in addon - module unification', function() { diff --git a/node-tests/fixtures/instance-initializer-test/mocha-rfc232.js b/node-tests/fixtures/instance-initializer-test/mocha-rfc232.js new file mode 100644 index 00000000000..9447560e6de --- /dev/null +++ b/node-tests/fixtures/instance-initializer-test/mocha-rfc232.js @@ -0,0 +1,28 @@ +import { expect } from 'chai'; +import { describe, it, beforeEach, afterEach } from 'mocha'; +import Application from '@ember/application'; +import { initialize } from 'my-app/instance-initializers/foo'; +import { run } from '@ember/runloop'; + +describe('Unit | Instance Initializer | foo', function() { + beforeEach(function() { + this.TestApplication = Application.extend(); + this.TestApplication.instanceInitializer({ + name: 'initializer under test', + initialize + }); + this.application = this.TestApplication.create({ autoboot: false }); + this.instance = this.application.buildInstance(); + }); + afterEach(function() { + run(this.instance, 'destroy'); + run(this.application, 'destroy'); + }); + + // Replace this with your real tests. + it('works', async function() { + await this.instance.boot(); + + expect(true).to.be.ok; + }); +}); diff --git a/node-tests/fixtures/instance-initializer-test/module-unification/mocha-rfc232.js b/node-tests/fixtures/instance-initializer-test/module-unification/mocha-rfc232.js new file mode 100644 index 00000000000..849828b0800 --- /dev/null +++ b/node-tests/fixtures/instance-initializer-test/module-unification/mocha-rfc232.js @@ -0,0 +1,28 @@ +import { expect } from 'chai'; +import { describe, it, beforeEach, afterEach } from 'mocha'; +import Application from '@ember/application'; +import { initialize } from 'my-app/init/instance-initializers/foo'; +import { run } from '@ember/runloop'; + +describe('Unit | Instance Initializer | foo', function() { + beforeEach(function() { + this.TestApplication = Application.extend(); + this.TestApplication.instanceInitializer({ + name: 'initializer under test', + initialize + }); + this.application = this.TestApplication.create({ autoboot: false }); + this.instance = this.application.buildInstance(); + }); + afterEach(function() { + run(this.instance, 'destroy'); + run(this.application, 'destroy'); + }); + + // Replace this with your real tests. + it('works', async function() { + await this.instance.boot(); + + expect(true).to.be.ok; + }); +});