Skip to content

Commit

Permalink
add RFC 232 mocha controller tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhaulagiri committed Sep 4, 2018
1 parent e565b03 commit d73ca4c
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';
import { setupTest } from 'ember-mocha';

describe('<%= friendlyTestDescription %>', function() {
setupTest();

// Replace this with your real tests.
it('exists', function() {
let controller = this.owner.lookup('controller:<%= controllerPathName %>');
expect(controller).to.be.ok;
});
});
52 changes: 52 additions & 0 deletions node-tests/blueprints/controller-test-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,32 @@ describe('Blueprint: controller-test', function() {
});
});
});

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

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

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

describe('in app - module unification', function() {
Expand Down Expand Up @@ -206,6 +232,32 @@ describe('Blueprint: controller-test', function() {
});
});
});

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

it('controller-test foo', function() {
return emberGenerateDestroy(['controller-test', 'foo'], _file => {
expect(_file('src/ui/routes/foo/controller-test.js')).to.equal(
fixture('controller-test/mocha-rfc232.js')
);
});
});

it('controller-test foo/bar', function() {
return emberGenerateDestroy(['controller-test', 'foo/bar'], _file => {
expect(_file('src/ui/routes/foo/bar/controller-test.js')).to.equal(
fixture('controller-test/mocha-rfc232-nested.js')
);
});
});
});
});

describe('in addon', function() {
Expand Down
13 changes: 13 additions & 0 deletions node-tests/fixtures/controller-test/mocha-rfc232-nested.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';
import { setupTest } from 'ember-mocha';

describe('Unit | Controller | foo/bar', function() {
setupTest();

// Replace this with your real tests.
it('exists', function() {
let controller = this.owner.lookup('controller:foo/bar');
expect(controller).to.be.ok;
});
});
13 changes: 13 additions & 0 deletions node-tests/fixtures/controller-test/mocha-rfc232.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';
import { setupTest } from 'ember-mocha';

describe('Unit | Controller | foo', function() {
setupTest();

// Replace this with your real tests.
it('exists', function() {
let controller = this.owner.lookup('controller:foo');
expect(controller).to.be.ok;
});
});

0 comments on commit d73ca4c

Please sign in to comment.