Skip to content

Commit

Permalink
Merge pull request #17411 from simonihmig/initializer-blueprint-mocha
Browse files Browse the repository at this point in the history
[Feature] Update initializer blueprint for ember-mocha 0.14
  • Loading branch information
rwjblue authored Mar 8, 2019
2 parents 6fbed54 + 84700f6 commit a03f18a
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';
import { setupTest } from 'ember-mocha';
import Application from '@ember/application';
import { initialize } from '<%= modulePrefix %>/initializers/<%= dasherizedModuleName %>';
<% if (destroyAppExists) { %>import destroyApp from '../../helpers/destroy-app';<% } else { %>import { run } from '@ember/runloop';<% } %>

describe('<%= friendlyTestName %>', function() {
hooks.beforeEach(function() {
this.TestApplication = Application.extend();
this.TestApplication.initializer({
name: 'initializer under test',
initialize
});

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

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

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

// you would normally confirm the results of the initializer here
expect(true).to.be.ok;
});
});
30 changes: 30 additions & 0 deletions node-tests/blueprints/initializer-test-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@ describe('Blueprint: initializer-test', function() {
});
});
});

describe('with [email protected]', function() {
beforeEach(function() {
modifyPackages([{ name: 'ember-qunit', delete: true }, { name: 'ember-mocha', dev: true }]);
generateFakePackageManifest('ember-mocha', '0.14.0');
});

it('initializer-test foo', function() {
return emberGenerateDestroy(['initializer-test', 'foo'], _file => {
expect(_file('tests/unit/initializers/foo-test.js')).to.equal(
fixture('initializer-test/mocha-rfc232.js')
);
});
});
});
});

describe('in addon', function() {
Expand Down Expand Up @@ -160,6 +175,21 @@ describe('Blueprint: initializer-test', function() {
});
});
});

describe('with [email protected]', function() {
beforeEach(function() {
modifyPackages([{ name: 'ember-qunit', delete: true }, { name: 'ember-mocha', dev: true }]);
generateFakePackageManifest('ember-mocha', '0.14.0');
});

it('initializer-test foo', function() {
return emberGenerateDestroy(['initializer-test', 'foo'], _file => {
expect(_file('src/init/initializers/foo-test.js')).to.equal(
fixture('initializer-test/module-unification/mocha-rfc232.js')
);
});
});
});
});

describe('in addon - module unification', function() {
Expand Down
30 changes: 30 additions & 0 deletions node-tests/fixtures/initializer-test/mocha-rfc232.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';
import { setupTest } from 'ember-mocha';
import Application from '@ember/application';
import { initialize } from 'my-app/initializers/foo';
import { run } from '@ember/runloop';

describe('Unit | Initializer | foo', function() {
hooks.beforeEach(function() {
this.TestApplication = Application.extend();
this.TestApplication.initializer({
name: 'initializer under test',
initialize
});

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

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

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

// you would normally confirm the results of the initializer here
expect(true).to.be.ok;
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';
import { setupTest } from 'ember-mocha';
import Application from '@ember/application';
import { initialize } from 'my-app/init/initializers/foo';
import { run } from '@ember/runloop';

describe('Unit | Initializer | foo', function() {
hooks.beforeEach(function() {
this.TestApplication = Application.extend();
this.TestApplication.initializer({
name: 'initializer under test',
initialize
});

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

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

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

// you would normally confirm the results of the initializer here
expect(true).to.be.ok;
});
});

0 comments on commit a03f18a

Please sign in to comment.