From d73ca4c96abbebc8ff060593dcf5f48eaddcd16c Mon Sep 17 00:00:00 2001 From: Brian Runnells Date: Fri, 17 Aug 2018 19:22:54 -0500 Subject: [PATCH] add RFC 232 mocha controller tests --- .../__testType__/__path__/__test__.js | 13 +++++ node-tests/blueprints/controller-test-test.js | 52 +++++++++++++++++++ .../controller-test/mocha-rfc232-nested.js | 13 +++++ .../fixtures/controller-test/mocha-rfc232.js | 13 +++++ 4 files changed, 91 insertions(+) create mode 100644 blueprints/controller-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js create mode 100644 node-tests/fixtures/controller-test/mocha-rfc232-nested.js create mode 100644 node-tests/fixtures/controller-test/mocha-rfc232.js diff --git a/blueprints/controller-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js b/blueprints/controller-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js new file mode 100644 index 00000000000..d6c0634d92c --- /dev/null +++ b/blueprints/controller-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js @@ -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; + }); +}); diff --git a/node-tests/blueprints/controller-test-test.js b/node-tests/blueprints/controller-test-test.js index b8adc2d2145..9fb75bfcabd 100644 --- a/node-tests/blueprints/controller-test-test.js +++ b/node-tests/blueprints/controller-test-test.js @@ -110,6 +110,32 @@ describe('Blueprint: controller-test', function() { }); }); }); + + describe('with ember-mocha@0.14.0', 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() { @@ -206,6 +232,32 @@ describe('Blueprint: controller-test', function() { }); }); }); + + describe('with ember-mocha@0.14.0', 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() { diff --git a/node-tests/fixtures/controller-test/mocha-rfc232-nested.js b/node-tests/fixtures/controller-test/mocha-rfc232-nested.js new file mode 100644 index 00000000000..fe082530619 --- /dev/null +++ b/node-tests/fixtures/controller-test/mocha-rfc232-nested.js @@ -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; + }); +}); diff --git a/node-tests/fixtures/controller-test/mocha-rfc232.js b/node-tests/fixtures/controller-test/mocha-rfc232.js new file mode 100644 index 00000000000..fc5348ddea0 --- /dev/null +++ b/node-tests/fixtures/controller-test/mocha-rfc232.js @@ -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; + }); +});