Skip to content

Commit

Permalink
[Feature] Update instance-initializer blueprint for ember-mocha 0.14
Browse files Browse the repository at this point in the history
Related to emberjs#16863
  • Loading branch information
simonihmig committed Mar 7, 2019
1 parent 4cad151 commit 5b0b146
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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;
});
});
30 changes: 30 additions & 0 deletions node-tests/blueprints/instance-initializer-test-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down
28 changes: 28 additions & 0 deletions node-tests/fixtures/instance-initializer-test/mocha-rfc232.js
Original file line number Diff line number Diff line change
@@ -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;
});
});
Original file line number Diff line number Diff line change
@@ -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;
});
});

0 comments on commit 5b0b146

Please sign in to comment.