diff --git a/packages/adapter/blueprints/adapter-test/index.js b/packages/adapter/blueprints/adapter-test/index.js index 5801515c8be..3181a7f245f 100644 --- a/packages/adapter/blueprints/adapter-test/index.js +++ b/packages/adapter/blueprints/adapter-test/index.js @@ -2,6 +2,7 @@ const path = require('path'); const testInfo = require('ember-cli-test-info'); const useTestFrameworkDetector = require('@ember-data/private-build-infra/src/utilities/test-framework-detector'); +const modulePrefixForProject = require('@ember-data/private-build-infra/src/utilities/module-prefix-for-project'); module.exports = useTestFrameworkDetector({ description: 'Generates an ember-data adapter unit test', @@ -22,6 +23,7 @@ module.exports = useTestFrameworkDetector({ locals(options) { return { friendlyTestDescription: testInfo.description(options.entity.name, 'Unit', 'Adapter'), + modulePrefix: modulePrefixForProject(options.project), }; }, }); diff --git a/packages/adapter/blueprints/adapter-test/mocha-rfc-232-files/__root__/__path__/__test__.js b/packages/adapter/blueprints/adapter-test/mocha-rfc-232-files/__root__/__path__/__test__.js index 7a6b2171320..0d176d9deef 100644 --- a/packages/adapter/blueprints/adapter-test/mocha-rfc-232-files/__root__/__path__/__test__.js +++ b/packages/adapter/blueprints/adapter-test/mocha-rfc-232-files/__root__/__path__/__test__.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; -import { setupTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupTest } from '<%= modulePrefix %>/tests/helpers'; describe('<%= friendlyTestDescription %>', function() { setupTest(); diff --git a/packages/adapter/blueprints/adapter-test/qunit-files/__root__/__path__/__test__.js b/packages/adapter/blueprints/adapter-test/qunit-files/__root__/__path__/__test__.js index 96b93a1200a..650251d4a09 100644 --- a/packages/adapter/blueprints/adapter-test/qunit-files/__root__/__path__/__test__.js +++ b/packages/adapter/blueprints/adapter-test/qunit-files/__root__/__path__/__test__.js @@ -1,5 +1,5 @@ import { module, test } from 'qunit'; -import { setupTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupTest } from '<%= modulePrefix %>/tests/helpers'; module('<%= friendlyTestDescription %>', function(hooks) { setupTest(hooks); diff --git a/packages/adapter/node-tests/blueprints/adapter-test.js b/packages/adapter/node-tests/blueprints/adapter-test.js index 362f63d44fa..6d86f33acef 100644 --- a/packages/adapter/node-tests/blueprints/adapter-test.js +++ b/packages/adapter/node-tests/blueprints/adapter-test.js @@ -266,4 +266,36 @@ describe('Acceptance: generate and destroy adapter blueprints', function () { }); }); }); + + describe('in addon', function () { + beforeEach(function () { + return emberNew({ target: 'addon' }); + }); + + describe('with ember-qunit (default)', function () { + it('adapter-test foo', function () { + return emberGenerateDestroy(['adapter-test', 'foo'], (_file) => { + expect(_file('tests/unit/adapters/foo-test.js')).to.equal(fixture(__dirname, 'adapter-test/rfc232-addon.js')); + }); + }); + }); + + describe('with ember-mocha', function () { + beforeEach(function () { + modifyPackages([ + { name: 'ember-qunit', delete: true }, + { name: 'ember-mocha', dev: true }, + ]); + generateFakePackageManifest('ember-mocha', '0.16.2'); + }); + + it('adapter-test foo', function () { + return emberGenerateDestroy(['adapter-test', 'foo'], (_file) => { + expect(_file('tests/unit/adapters/foo-test.js')).to.equal( + fixture(__dirname, 'adapter-test/mocha-rfc232-addon.js') + ); + }); + }); + }); + }); }); diff --git a/packages/adapter/node-tests/fixtures/adapter-test/mocha-rfc232-addon.js b/packages/adapter/node-tests/fixtures/adapter-test/mocha-rfc232-addon.js new file mode 100644 index 00000000000..aef8747276f --- /dev/null +++ b/packages/adapter/node-tests/fixtures/adapter-test/mocha-rfc232-addon.js @@ -0,0 +1,13 @@ +import { expect } from 'chai'; +import { describe, it } from 'mocha'; +import { setupTest } from 'dummy/tests/helpers'; + +describe('Unit | Adapter | foo', function() { + setupTest(); + + // Replace this with your real tests. + it('exists', function() { + let adapter = this.owner.lookup('adapter:foo'); + expect(adapter).to.be.ok; + }); +}); diff --git a/packages/adapter/node-tests/fixtures/adapter-test/rfc232-addon.js b/packages/adapter/node-tests/fixtures/adapter-test/rfc232-addon.js new file mode 100644 index 00000000000..4242b66d1dc --- /dev/null +++ b/packages/adapter/node-tests/fixtures/adapter-test/rfc232-addon.js @@ -0,0 +1,12 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'dummy/tests/helpers'; + +module('Unit | Adapter | foo', function(hooks) { + setupTest(hooks); + + // Replace this with your real tests. + test('it exists', function(assert) { + let adapter = this.owner.lookup('adapter:foo'); + assert.ok(adapter); + }); +}); diff --git a/packages/model/blueprints/model-test/index.js b/packages/model/blueprints/model-test/index.js index 56fc5e319f1..b01f451f624 100644 --- a/packages/model/blueprints/model-test/index.js +++ b/packages/model/blueprints/model-test/index.js @@ -2,6 +2,7 @@ const path = require('path'); const testInfo = require('ember-cli-test-info'); const useTestFrameworkDetector = require('@ember-data/private-build-infra/src/utilities/test-framework-detector'); +const modulePrefixForProject = require('@ember-data/private-build-infra/src/utilities/module-prefix-for-project'); const ModelBlueprint = require('../model'); @@ -25,6 +26,7 @@ module.exports = useTestFrameworkDetector({ const result = ModelBlueprint.locals.apply(this, arguments); result.friendlyTestDescription = testInfo.description(options.entity.name, 'Unit', 'Model'); + result.modulePrefix = modulePrefixForProject(options.project); return result; }, diff --git a/packages/model/blueprints/model-test/mocha-rfc-232-files/__root__/__path__/__test__.js b/packages/model/blueprints/model-test/mocha-rfc-232-files/__root__/__path__/__test__.js index 2ab8fe077c5..88eef250b1c 100644 --- a/packages/model/blueprints/model-test/mocha-rfc-232-files/__root__/__path__/__test__.js +++ b/packages/model/blueprints/model-test/mocha-rfc-232-files/__root__/__path__/__test__.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; -import { setupTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupTest } from '<%= modulePrefix %>/tests/helpers'; describe('<%= friendlyTestDescription %>', function() { setupTest(); diff --git a/packages/model/blueprints/model-test/qunit-files/__root__/__path__/__test__.js b/packages/model/blueprints/model-test/qunit-files/__root__/__path__/__test__.js index 750aa9e9bb4..1df741e59ff 100644 --- a/packages/model/blueprints/model-test/qunit-files/__root__/__path__/__test__.js +++ b/packages/model/blueprints/model-test/qunit-files/__root__/__path__/__test__.js @@ -1,5 +1,5 @@ import { module, test } from 'qunit'; -import { setupTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupTest } from '<%= modulePrefix %>/tests/helpers'; module('<%= friendlyTestDescription %>', function(hooks) { setupTest(hooks); diff --git a/packages/model/node-tests/blueprints/model-test.js b/packages/model/node-tests/blueprints/model-test.js index 0b4ff92ed78..174b62d6df4 100644 --- a/packages/model/node-tests/blueprints/model-test.js +++ b/packages/model/node-tests/blueprints/model-test.js @@ -298,4 +298,36 @@ describe('Acceptance: generate and destroy model blueprints', function () { }); }); }); + + describe('in addon', function () { + beforeEach(function () { + return emberNew({ target: 'addon' }); + }); + + describe('with ember-qunit (default)', function () { + it('model-test foo', function () { + return emberGenerateDestroy(['model-test', 'foo'], (_file) => { + expect(_file('tests/unit/models/foo-test.js')).to.equal(fixture(__dirname, 'model-test/rfc232-addon.js')); + }); + }); + }); + + describe('with ember-mocha', function () { + beforeEach(function () { + modifyPackages([ + { name: 'ember-qunit', delete: true }, + { name: 'ember-mocha', dev: true }, + ]); + generateFakePackageManifest('ember-mocha', '0.16.2'); + }); + + it('model-test foo', function () { + return emberGenerateDestroy(['model-test', 'foo'], (_file) => { + expect(_file('tests/unit/models/foo-test.js')).to.equal( + fixture(__dirname, 'model-test/mocha-rfc232-addon.js') + ); + }); + }); + }); + }); }); diff --git a/packages/model/node-tests/fixtures/model-test/mocha-rfc232-addon.js b/packages/model/node-tests/fixtures/model-test/mocha-rfc232-addon.js new file mode 100644 index 00000000000..bd6e56cb760 --- /dev/null +++ b/packages/model/node-tests/fixtures/model-test/mocha-rfc232-addon.js @@ -0,0 +1,14 @@ +import { expect } from 'chai'; +import { describe, it } from 'mocha'; +import { setupTest } from 'dummy/tests/helpers'; + +describe('Unit | Model | foo', function() { + setupTest(); + + // Replace this with your real tests. + it('exists', function() { + let store = this.owner.lookup('service:store'); + let model = store.createRecord('foo', {}); + expect(model).to.be.ok; + }); +}); diff --git a/packages/model/node-tests/fixtures/model-test/rfc232-addon.js b/packages/model/node-tests/fixtures/model-test/rfc232-addon.js new file mode 100644 index 00000000000..9b8015e7aaa --- /dev/null +++ b/packages/model/node-tests/fixtures/model-test/rfc232-addon.js @@ -0,0 +1,13 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'dummy/tests/helpers'; + +module('Unit | Model | foo', function(hooks) { + setupTest(hooks); + + // Replace this with your real tests. + test('it exists', function(assert) { + let store = this.owner.lookup('service:store'); + let model = store.createRecord('foo', {}); + assert.ok(model); + }); +}); diff --git a/packages/private-build-infra/src/utilities/module-prefix-for-project.js b/packages/private-build-infra/src/utilities/module-prefix-for-project.js new file mode 100644 index 00000000000..bd051380526 --- /dev/null +++ b/packages/private-build-infra/src/utilities/module-prefix-for-project.js @@ -0,0 +1,5 @@ +const { dasherize } = require('ember-cli-string-utils'); + +module.exports = function modulePrefixForProject(project) { + return dasherize(project.config().modulePrefix); +}; diff --git a/packages/serializer/blueprints/serializer-test/index.js b/packages/serializer/blueprints/serializer-test/index.js index 50feae8d6df..ad806f42ed0 100644 --- a/packages/serializer/blueprints/serializer-test/index.js +++ b/packages/serializer/blueprints/serializer-test/index.js @@ -2,6 +2,7 @@ const path = require('path'); const testInfo = require('ember-cli-test-info'); const useTestFrameworkDetector = require('@ember-data/private-build-infra/src/utilities/test-framework-detector'); +const modulePrefixForProject = require('@ember-data/private-build-infra/src/utilities/module-prefix-for-project'); module.exports = useTestFrameworkDetector({ description: 'Generates a serializer unit test.', @@ -22,6 +23,7 @@ module.exports = useTestFrameworkDetector({ locals(options) { return { friendlyTestDescription: testInfo.description(options.entity.name, 'Unit', 'Serializer'), + modulePrefix: modulePrefixForProject(options.project), }; }, }); diff --git a/packages/serializer/blueprints/serializer-test/mocha-rfc-232-files/__root__/__path__/__test__.js b/packages/serializer/blueprints/serializer-test/mocha-rfc-232-files/__root__/__path__/__test__.js index ee572c68f3e..6ed40ad4e1c 100644 --- a/packages/serializer/blueprints/serializer-test/mocha-rfc-232-files/__root__/__path__/__test__.js +++ b/packages/serializer/blueprints/serializer-test/mocha-rfc-232-files/__root__/__path__/__test__.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; -import { setupTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupTest } from '<%= modulePrefix %>/tests/helpers'; describe('<%= friendlyTestDescription %>', function() { setupTest(); diff --git a/packages/serializer/blueprints/serializer-test/qunit-files/__root__/__path__/__test__.js b/packages/serializer/blueprints/serializer-test/qunit-files/__root__/__path__/__test__.js index 0188ffb45be..f7be49b8156 100644 --- a/packages/serializer/blueprints/serializer-test/qunit-files/__root__/__path__/__test__.js +++ b/packages/serializer/blueprints/serializer-test/qunit-files/__root__/__path__/__test__.js @@ -1,5 +1,5 @@ import { module, test } from 'qunit'; -import { setupTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupTest } from '<%= modulePrefix %>/tests/helpers'; module('<%= friendlyTestDescription %>', function(hooks) { setupTest(hooks); diff --git a/packages/serializer/blueprints/transform-test/index.js b/packages/serializer/blueprints/transform-test/index.js index 370f6fde720..6d90912f4ee 100644 --- a/packages/serializer/blueprints/transform-test/index.js +++ b/packages/serializer/blueprints/transform-test/index.js @@ -2,6 +2,7 @@ const path = require('path'); const testInfo = require('ember-cli-test-info'); const useTestFrameworkDetector = require('@ember-data/private-build-infra/src/utilities/test-framework-detector'); +const modulePrefixForProject = require('@ember-data/private-build-infra/src/utilities/module-prefix-for-project'); module.exports = useTestFrameworkDetector({ description: 'Generates a transform unit test.', @@ -22,6 +23,7 @@ module.exports = useTestFrameworkDetector({ locals(options) { return { friendlyTestDescription: testInfo.description(options.entity.name, 'Unit', 'Transform'), + modulePrefix: modulePrefixForProject(options.project), }; }, }); diff --git a/packages/serializer/blueprints/transform-test/mocha-rfc-232-files/__root__/__path__/__test__.js b/packages/serializer/blueprints/transform-test/mocha-rfc-232-files/__root__/__path__/__test__.js index d90e27a0d5b..ec57932f3aa 100644 --- a/packages/serializer/blueprints/transform-test/mocha-rfc-232-files/__root__/__path__/__test__.js +++ b/packages/serializer/blueprints/transform-test/mocha-rfc-232-files/__root__/__path__/__test__.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; -import { setupTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupTest } from '<%= modulePrefix %>/tests/helpers'; describe('<%= friendlyTestDescription %>', function() { setupTest(); diff --git a/packages/serializer/blueprints/transform-test/qunit-files/__root__/__path__/__test__.js b/packages/serializer/blueprints/transform-test/qunit-files/__root__/__path__/__test__.js index 332fc3d746b..72e6ce3ce54 100644 --- a/packages/serializer/blueprints/transform-test/qunit-files/__root__/__path__/__test__.js +++ b/packages/serializer/blueprints/transform-test/qunit-files/__root__/__path__/__test__.js @@ -1,5 +1,5 @@ import { module, test } from 'qunit'; -import { setupTest } from '<%= dasherizedPackageName %>/tests/helpers'; +import { setupTest } from '<%= modulePrefix %>/tests/helpers'; module('<%= friendlyTestDescription %>', function(hooks) { setupTest(hooks); diff --git a/packages/serializer/node-tests/blueprints/serializer-test.js b/packages/serializer/node-tests/blueprints/serializer-test.js index 9725e892270..61dc175373a 100644 --- a/packages/serializer/node-tests/blueprints/serializer-test.js +++ b/packages/serializer/node-tests/blueprints/serializer-test.js @@ -281,4 +281,38 @@ describe('Acceptance: generate and destroy serializer blueprints', function () { }); }); }); + + describe('in addon', function () { + beforeEach(function () { + return emberNew({ target: 'addon' }); + }); + + describe('with ember-qunit (default)', function () { + it('serializer-test foo', function () { + return emberGenerateDestroy(['serializer-test', 'foo'], (_file) => { + expect(_file('tests/unit/serializers/foo-test.js')).to.equal( + fixture(__dirname, 'serializer-test/rfc232-addon.js') + ); + }); + }); + }); + + describe('with ember-mocha', function () { + beforeEach(function () { + modifyPackages([ + { name: 'ember-qunit', delete: true }, + { name: 'ember-mocha', dev: true }, + ]); + generateFakePackageManifest('ember-mocha', '0.16.2'); + }); + + it('serializer-test foo', function () { + return emberGenerateDestroy(['serializer-test', 'foo'], (_file) => { + expect(_file('tests/unit/serializers/foo-test.js')).to.equal( + fixture(__dirname, 'serializer-test/mocha-rfc232-addon.js') + ); + }); + }); + }); + }); }); diff --git a/packages/serializer/node-tests/blueprints/transform-test.js b/packages/serializer/node-tests/blueprints/transform-test.js index 2dc821f19f1..7af7773f242 100644 --- a/packages/serializer/node-tests/blueprints/transform-test.js +++ b/packages/serializer/node-tests/blueprints/transform-test.js @@ -195,4 +195,38 @@ describe('Acceptance: generate and destroy transform blueprints', function () { }); }); }); + + describe('in addon', function () { + beforeEach(function () { + return emberNew({ target: 'addon' }); + }); + + describe('with ember-qunit (default)', function () { + it('transform-test foo', function () { + return emberGenerateDestroy(['transform-test', 'foo'], (_file) => { + expect(_file('tests/unit/transforms/foo-test.js')).to.equal( + fixture(__dirname, 'transform-test/rfc232-addon.js') + ); + }); + }); + }); + + describe('with ember-mocha', function () { + beforeEach(function () { + modifyPackages([ + { name: 'ember-qunit', delete: true }, + { name: 'ember-mocha', dev: true }, + ]); + generateFakePackageManifest('ember-mocha', '0.16.2'); + }); + + it('transform-test foo', function () { + return emberGenerateDestroy(['transform-test', 'foo'], (_file) => { + expect(_file('tests/unit/transforms/foo-test.js')).to.equal( + fixture(__dirname, 'transform-test/mocha-rfc232-addon.js') + ); + }); + }); + }); + }); }); diff --git a/packages/serializer/node-tests/fixtures/serializer-test/mocha-rfc232-addon.js b/packages/serializer/node-tests/fixtures/serializer-test/mocha-rfc232-addon.js new file mode 100644 index 00000000000..c6955198e94 --- /dev/null +++ b/packages/serializer/node-tests/fixtures/serializer-test/mocha-rfc232-addon.js @@ -0,0 +1,24 @@ +import { expect } from 'chai'; +import { describe, it } from 'mocha'; +import { setupTest } from 'dummy/tests/helpers'; + +describe('Unit | Serializer | foo', function() { + setupTest(); + + // Replace this with your real tests. + it('exists', function() { + let store = this.owner.lookup('service:store'); + let serializer = store.serializerFor('foo'); + + expect(serializer).to.be.ok; + }); + + it('serializes records', function() { + let store = this.owner.lookup('service:store'); + let record = store.createRecord('foo', {}); + + let serializedRecord = record.serialize(); + + expect(serializedRecord).to.be.ok; + }); +}); diff --git a/packages/serializer/node-tests/fixtures/serializer-test/rfc232-addon.js b/packages/serializer/node-tests/fixtures/serializer-test/rfc232-addon.js new file mode 100644 index 00000000000..6a7ecd7c22e --- /dev/null +++ b/packages/serializer/node-tests/fixtures/serializer-test/rfc232-addon.js @@ -0,0 +1,23 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'dummy/tests/helpers'; + +module('Unit | Serializer | foo', function(hooks) { + setupTest(hooks); + + // Replace this with your real tests. + test('it exists', function(assert) { + let store = this.owner.lookup('service:store'); + let serializer = store.serializerFor('foo'); + + assert.ok(serializer); + }); + + test('it serializes records', function(assert) { + let store = this.owner.lookup('service:store'); + let record = store.createRecord('foo', {}); + + let serializedRecord = record.serialize(); + + assert.ok(serializedRecord); + }); +}); diff --git a/packages/serializer/node-tests/fixtures/transform-test/mocha-rfc232-addon.js b/packages/serializer/node-tests/fixtures/transform-test/mocha-rfc232-addon.js new file mode 100644 index 00000000000..07c38e81ad7 --- /dev/null +++ b/packages/serializer/node-tests/fixtures/transform-test/mocha-rfc232-addon.js @@ -0,0 +1,13 @@ +import { expect } from 'chai'; +import { describe, it } from 'mocha'; +import { setupTest } from 'dummy/tests/helpers'; + +describe('Unit | Transform | foo', function() { + setupTest(); + + // Replace this with your real tests. + it('exists', function() { + let transform = this.owner.lookup('transform:foo'); + expect(transform).to.be.ok; + }); +}); diff --git a/packages/serializer/node-tests/fixtures/transform-test/rfc232-addon.js b/packages/serializer/node-tests/fixtures/transform-test/rfc232-addon.js new file mode 100644 index 00000000000..dcecb36685b --- /dev/null +++ b/packages/serializer/node-tests/fixtures/transform-test/rfc232-addon.js @@ -0,0 +1,12 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'dummy/tests/helpers'; + +module('Unit | Transform | foo', function(hooks) { + setupTest(hooks); + + // Replace this with your real tests. + test('it exists', function(assert) { + let transform = this.owner.lookup('transform:foo'); + assert.ok(transform); + }); +});