diff --git a/blueprints/-addon-import.js b/blueprints/-addon-import.js new file mode 100644 index 0000000..3b83f2b --- /dev/null +++ b/blueprints/-addon-import.js @@ -0,0 +1,54 @@ +/*jshint node:true*/ + +var stringUtil = require('ember-cli-string-utils'); +var path = require('path'); +var inflector = require('inflection'); + +module.exports = { + description: 'Generates an import wrapper.', + + fileMapTokens: function() { + return { + __name__: function(options) { + if (options.pod && options.hasPathToken) { + return options.locals.blueprintName; + } + return options.dasherizedModuleName; + }, + __path__: function(options) { + if (options.pod && options.hasPathToken) { + return path.join(options.podPath, options.dasherizedModuleName); + } + return inflector.pluralize(options.locals.blueprintName); + }, + __root__: function(options) { + if (options.inRepoAddon) { + return path.join('lib', options.inRepoAddon, 'app'); + } + return 'app'; + } + }; + }, + + locals: function(options) { + var addonRawName = options.inRepoAddon ? options.inRepoAddon : options.project.name(); + var addonName = stringUtil.dasherize(addonRawName); + var fileName = stringUtil.dasherize(options.entity.name); + var blueprintName = options.originBlueprintName; + var modulePathSegments = [addonName, inflector.pluralize(options.originBlueprintName), fileName]; + + if (blueprintName.match(/-addon/)) { + blueprintName = blueprintName.substr(0,blueprintName.indexOf('-addon')); + modulePathSegments = [addonName, inflector.pluralize(blueprintName), fileName]; + } + + if (options.pod) { + modulePathSegments = [addonName, fileName, blueprintName]; + } + + return { + modulePath: modulePathSegments.join('/'), + blueprintName: blueprintName + }; + } +}; diff --git a/blueprints/acceptance-test/files/tests/acceptance/__name__-test.js b/blueprints/acceptance-test/files/tests/acceptance/__name__-test.js deleted file mode 100644 index 580ceca..0000000 --- a/blueprints/acceptance-test/files/tests/acceptance/__name__-test.js +++ /dev/null @@ -1,21 +0,0 @@ -import { module, test } from 'qunit'; -import startApp from '<%= testFolderRoot %>/tests/helpers/start-app'; -import destroyApp from '<%= testFolderRoot %>/tests/helpers/destroy-app'; - -module('<%= friendlyTestName %>', { - beforeEach: function() { - this.application = startApp(); - }, - - afterEach: function() { - destroyApp(this.application); - } -}); - -test('visiting /<%= dasherizedModuleName %>', function(assert) { - visit('/<%= dasherizedModuleName %>'); - - andThen(function() { - assert.equal(currentURL(), '/<%= dasherizedModuleName %>'); - }); -}); diff --git a/blueprints/acceptance-test/index.js b/blueprints/acceptance-test/index.js index 72836e2..2a358d5 100644 --- a/blueprints/acceptance-test/index.js +++ b/blueprints/acceptance-test/index.js @@ -3,18 +3,27 @@ var testInfo = require('ember-cli-test-info'); var pathUtil = require('ember-cli-path-utils'); var stringUtils = require('ember-cli-string-utils'); +var existsSync = require('exists-sync'); +var path = require('path'); +var useTestFrameworkDetector = require('../test-framework-detector'); -module.exports = { +module.exports = useTestFrameworkDetector({ description: 'Generates an acceptance test for a feature.', + locals: function(options) { var testFolderRoot = stringUtils.dasherize(options.project.name()); if (options.project.isEmberCLIAddon()) { testFolderRoot = pathUtil.getRelativeParentPath(options.entity.name, -1, false); } + + var destroyAppExists = + existsSync(path.join(this.project.root, '/tests/helpers/destroy-app.js')); + return { testFolderRoot: testFolderRoot, - friendlyTestName: testInfo.name(options.entity.name, "Acceptance", null) + friendlyTestName: testInfo.name(options.entity.name, 'Acceptance', null), + destroyAppExists: destroyAppExists }; } -}; +}); diff --git a/blueprints/acceptance-test/mocha-files/tests/acceptance/__name__-test.js b/blueprints/acceptance-test/mocha-files/tests/acceptance/__name__-test.js new file mode 100644 index 0000000..fb8e9ca --- /dev/null +++ b/blueprints/acceptance-test/mocha-files/tests/acceptance/__name__-test.js @@ -0,0 +1,25 @@ +/* jshint expr:true */ +import { describe, it, beforeEach, afterEach } from 'mocha'; +import { expect } from 'chai'; +import startApp from '../helpers/start-app'; +<% if (destroyAppExists) { %>import destroyApp from '../helpers/destroy-app';<% } else { %>import Ember from 'ember';<% } %> + +describe('<%= friendlyTestName %>', function() { + let application; + + beforeEach(function() { + application = startApp(); + }); + + afterEach(function() { + <% if (destroyAppExists) { %>destroyApp(application);<% } else { %>Ember.run(application, 'destroy');<% } %> + }); + + it('can visit /<%= dasherizedModuleName %>', function() { + visit('/<%= dasherizedModuleName %>'); + + andThen(function() { + expect(currentURL()).to.equal('/<%= dasherizedModuleName %>'); + }); + }); +}); diff --git a/blueprints/acceptance-test/qunit-files/tests/acceptance/__name__-test.js b/blueprints/acceptance-test/qunit-files/tests/acceptance/__name__-test.js new file mode 100644 index 0000000..abbcab2 --- /dev/null +++ b/blueprints/acceptance-test/qunit-files/tests/acceptance/__name__-test.js @@ -0,0 +1,12 @@ +import { test } from 'qunit'; +import moduleForAcceptance from '<%= testFolderRoot %>/tests/helpers/module-for-acceptance'; + +moduleForAcceptance('<%= friendlyTestName %>'); + +test('visiting /<%= dasherizedModuleName %>', function(assert) { + visit('/<%= dasherizedModuleName %>'); + + andThen(function() { + assert.equal(currentURL(), '/<%= dasherizedModuleName %>'); + }); +}); diff --git a/blueprints/component-addon/index.js b/blueprints/component-addon/index.js index 9501014..626e24e 100644 --- a/blueprints/component-addon/index.js +++ b/blueprints/component-addon/index.js @@ -1,8 +1,8 @@ /*jshint node:true*/ var stringUtil = require('ember-cli-string-utils'); -var validComponentName = require('ember-cli/lib/utilities/valid-component-name'); -var getPathOption = require('ember-cli/lib/utilities/get-component-path-option'); +var validComponentName = require('ember-cli-valid-component-name'); +var getPathOption = require('ember-cli-get-component-path-option'); var path = require('path'); var normalizeEntityName = require('ember-cli-normalize-entity-name'); diff --git a/blueprints/component-test/index.js b/blueprints/component-test/index.js index 68d6dbf..8a14227 100644 --- a/blueprints/component-test/index.js +++ b/blueprints/component-test/index.js @@ -3,9 +3,11 @@ var path = require('path'); var testInfo = require('ember-cli-test-info'); var stringUtil = require('ember-cli-string-utils'); -var getPathOption = require('ember-cli/lib/utilities/get-component-path-option'); +var isPackageMissing = require('ember-cli-is-package-missing'); +var getPathOption = require('ember-cli-get-component-path-option'); +var useTestFrameworkDetector = require('../test-framework-detector'); -module.exports = { +module.exports = useTestFrameworkDetector({ description: 'Generates a component integration or unit test.', availableOptions: [ @@ -38,15 +40,15 @@ module.exports = { locals: function(options) { var dasherizedModuleName = stringUtil.dasherize(options.entity.name); var componentPathName = dasherizedModuleName; - var testType = options.testType || "integration"; - var friendlyTestDescription = testInfo.description(options.entity.name, "Integration", "Component"); + var testType = options.testType || 'integration'; + var friendlyTestDescription = testInfo.description(options.entity.name, 'Integration', 'Component'); if (options.pod && options.path !== 'components' && options.path !== '') { componentPathName = [options.path, dasherizedModuleName].join('/'); } if (options.testType === 'unit') { - friendlyTestDescription = testInfo.description(options.entity.name, "Unit", "Component"); + friendlyTestDescription = testInfo.description(options.entity.name, 'Unit', 'Component'); } return { @@ -55,5 +57,12 @@ module.exports = { componentPathName: componentPathName, friendlyTestDescription: friendlyTestDescription }; + }, + afterInstall: function(options) { + if (!options.dryRun && options.testType === 'integration' && isPackageMissing(this, 'ember-cli-htmlbars-inline-precompile')) { + return this.addPackagesToProject([ + { name: 'ember-cli-htmlbars-inline-precompile', target: '^0.3.1' } + ]); + } } -}; +}); diff --git a/blueprints/component-test/mocha-files/tests/__testType__/__path__/__test__.js b/blueprints/component-test/mocha-files/tests/__testType__/__path__/__test__.js new file mode 100644 index 0000000..d09de15 --- /dev/null +++ b/blueprints/component-test/mocha-files/tests/__testType__/__path__/__test__.js @@ -0,0 +1,32 @@ +/* jshint expr:true */ +import { expect } from 'chai'; +import { describeComponent, it } from 'ember-mocha';<% if (testType === 'integration') { %> +import hbs from 'htmlbars-inline-precompile';<% } %> + +describeComponent('<%= componentPathName %>', '<%= friendlyTestDescription %>', + { + <% if (testType === 'integration' ) { %>integration: true<% } else if(testType === 'unit') { %>// Specify the other units that are required for this test + // needs: ['component:foo', 'helper:bar'], + unit: true<% } %> + }, + function() { + it('renders', function() { + <% if (testType === 'integration' ) { %>// Set any properties with this.set('myProperty', 'value'); + // Handle any actions with this.on('myAction', function(val) { ... }); + // Template block usage: + // this.render(hbs` + // {{#<%= dasherizedModuleName %>}} + // template content + // {{/<%= dasherizedModuleName %>}} + // `); + + this.render(hbs`{{<%= dasherizedModuleName %>}}`); + expect(this.$()).to.have.length(1);<% } else if(testType === 'unit') { %>// creates the component instance + let component = this.subject(); + // renders the component on the page + this.render(); + expect(component).to.be.ok; + expect(this.$()).to.have.length(1);<% } %> + }); + } +); diff --git a/blueprints/component-test/files/tests/__testType__/__path__/__test__.js b/blueprints/component-test/qunit-files/tests/__testType__/__path__/__test__.js similarity index 78% rename from blueprints/component-test/files/tests/__testType__/__path__/__test__.js rename to blueprints/component-test/qunit-files/tests/__testType__/__path__/__test__.js index 84d0fe7..faf52d9 100644 --- a/blueprints/component-test/files/tests/__testType__/__path__/__test__.js +++ b/blueprints/component-test/qunit-files/tests/__testType__/__path__/__test__.js @@ -8,26 +8,23 @@ moduleForComponent('<%= componentPathName %>', '<%= friendlyTestDescription %>', }); test('it renders', function(assert) { - <% if (testType === 'integration' ) { %>assert.expect(2); - - // Set any properties with this.set('myProperty', 'value'); - // Handle any actions with this.on('myAction', function(val) { ... });" + EOL + EOL + + <% if (testType === 'integration' ) { %>// Set any properties with this.set('myProperty', 'value'); + // Handle any actions with this.on('myAction', function(val) { ... }); this.render(hbs`{{<%= componentPathName %>}}`); assert.equal(this.$().text().trim(), ''); - // Template block usage:" + EOL + + // Template block usage: this.render(hbs` {{#<%= componentPathName %>}} template block text {{/<%= componentPathName %>}} `); - assert.equal(this.$().text().trim(), 'template block text');<% } else if(testType === 'unit') { %>assert.expect(1); - + assert.equal(this.$().text().trim(), 'template block text');<% } else if(testType === 'unit') { %> // Creates the component instance - /*var component =*/ this.subject(); + /*let component =*/ this.subject(); // Renders the component to the page this.render(); assert.equal(this.$().text().trim(), '');<% } %> diff --git a/blueprints/component/index.js b/blueprints/component/index.js index 679f033..bcfaf3c 100644 --- a/blueprints/component/index.js +++ b/blueprints/component/index.js @@ -2,8 +2,8 @@ var stringUtil = require('ember-cli-string-utils'); var pathUtil = require('ember-cli-path-utils'); -var validComponentName = require('ember-cli/lib/utilities/valid-component-name'); -var getPathOption = require('ember-cli/lib/utilities/get-component-path-option'); +var validComponentName = require('ember-cli-valid-component-name'); +var getPathOption = require('ember-cli-get-component-path-option'); var path = require('path'); var normalizeEntityName = require('ember-cli-normalize-entity-name'); @@ -64,7 +64,7 @@ module.exports = { 'templates/components/' + stringUtil.dasherize(options.entity.name); } importTemplate = 'import layout from \'' + templatePath + '\';\n'; - contents = '\n layout: layout'; + contents = '\n layout'; } return { diff --git a/blueprints/controller-test/index.js b/blueprints/controller-test/index.js index 3f25677..d13a07b 100644 --- a/blueprints/controller-test/index.js +++ b/blueprints/controller-test/index.js @@ -1,5 +1,13 @@ /*jshint node:true*/ -module.exports = { - description: 'Generates a controller unit test.' -}; +var testInfo = require('ember-cli-test-info'); +var useTestFrameworkDetector = require('../test-framework-detector'); + +module.exports = useTestFrameworkDetector({ + description: 'Generates a controller unit test.', + locals: function(options) { + return { + friendlyTestDescription: testInfo.description(options.entity.name, 'Unit', 'Controller') + }; + } +}); diff --git a/blueprints/controller-test/mocha-files/tests/unit/__path__/__test__.js b/blueprints/controller-test/mocha-files/tests/unit/__path__/__test__.js new file mode 100644 index 0000000..35039ac --- /dev/null +++ b/blueprints/controller-test/mocha-files/tests/unit/__path__/__test__.js @@ -0,0 +1,17 @@ +/* jshint expr:true */ +import { expect } from 'chai'; +import { describeModule, it } from 'ember-mocha'; + +describeModule('controller:<%= dasherizedModuleName %>', '<%= friendlyTestDescription %>', + { + // Specify the other units that are required for this test. + // needs: ['controller:foo'] + }, + function() { + // Replace this with your real tests. + it('exists', function() { + let controller = this.subject(); + expect(controller).to.be.ok; + }); + } +); diff --git a/blueprints/controller-test/files/tests/unit/__path__/__test__.js b/blueprints/controller-test/qunit-files/tests/unit/__path__/__test__.js similarity index 67% rename from blueprints/controller-test/files/tests/unit/__path__/__test__.js rename to blueprints/controller-test/qunit-files/tests/unit/__path__/__test__.js index 0528f3d..db26bfa 100644 --- a/blueprints/controller-test/files/tests/unit/__path__/__test__.js +++ b/blueprints/controller-test/qunit-files/tests/unit/__path__/__test__.js @@ -1,12 +1,12 @@ import { moduleFor, test } from 'ember-qunit'; -moduleFor('controller:<%= dasherizedModuleName %>', { +moduleFor('controller:<%= dasherizedModuleName %>', '<%= friendlyTestDescription %>', { // Specify the other units that are required for this test. // needs: ['controller:foo'] }); // Replace this with your real tests. test('it exists', function(assert) { - var controller = this.subject(); + let controller = this.subject(); assert.ok(controller); }); diff --git a/blueprints/helper-addon/index.js b/blueprints/helper-addon/index.js index 913fb8d..270f28f 100644 --- a/blueprints/helper-addon/index.js +++ b/blueprints/helper-addon/index.js @@ -1,3 +1,3 @@ /*jshint node:true*/ -module.exports = require('ember-cli/blueprints/addon-import'); +module.exports = require('../-addon-import'); diff --git a/blueprints/helper-test/index.js b/blueprints/helper-test/index.js index b0d1a2a..5d3afcf 100644 --- a/blueprints/helper-test/index.js +++ b/blueprints/helper-test/index.js @@ -1,14 +1,15 @@ /*jshint node:true*/ -var getDependencyDepth = require('ember-cli-get-dependency-depth'); var testInfo = require('ember-cli-test-info'); +var stringUtils = require('ember-cli-string-utils'); +var useTestFrameworkDetector = require('../test-framework-detector'); -module.exports = { +module.exports = useTestFrameworkDetector({ description: 'Generates a helper unit test.', locals: function(options) { return { - friendlyTestName: testInfo.name(options.entity.name, "Unit", "Helper"), - dependencyDepth: getDependencyDepth(options.entity.name) + friendlyTestName: testInfo.name(options.entity.name, 'Unit', 'Helper'), + dasherizedModulePrefix: stringUtils.dasherize(options.project.config().modulePrefix) }; } -}; +}); diff --git a/blueprints/helper-test/mocha-files/tests/unit/helpers/__name__-test.js b/blueprints/helper-test/mocha-files/tests/unit/helpers/__name__-test.js new file mode 100644 index 0000000..85c42e7 --- /dev/null +++ b/blueprints/helper-test/mocha-files/tests/unit/helpers/__name__-test.js @@ -0,0 +1,12 @@ +/* jshint expr:true */ +import { expect } from 'chai'; +import { describe, it } from 'mocha'; +import { <%= camelizedModuleName %> } from '<%= dasherizedPackageName %>/helpers/<%= dasherizedModuleName %>'; + +describe('<%= friendlyTestName %>', function() { + // Replace this with your real tests. + it('works', function() { + let result = <%= camelizedModuleName %>(42); + expect(result).to.be.ok; + }); +}); diff --git a/blueprints/helper-test/files/tests/unit/helpers/__name__-test.js b/blueprints/helper-test/qunit-files/tests/unit/helpers/__name__-test.js similarity index 51% rename from blueprints/helper-test/files/tests/unit/helpers/__name__-test.js rename to blueprints/helper-test/qunit-files/tests/unit/helpers/__name__-test.js index 5ef494e..25a5954 100644 --- a/blueprints/helper-test/files/tests/unit/helpers/__name__-test.js +++ b/blueprints/helper-test/qunit-files/tests/unit/helpers/__name__-test.js @@ -1,10 +1,10 @@ -import { <%= camelizedModuleName %> } from '<%= dependencyDepth %>/helpers/<%= dasherizedModuleName %>'; +import { <%= camelizedModuleName %> } from '<%= dasherizedModulePrefix %>/helpers/<%= dasherizedModuleName %>'; import { module, test } from 'qunit'; module('<%= friendlyTestName %>'); // Replace this with your real tests. test('it works', function(assert) { - var result = <%= camelizedModuleName %>(42); + let result = <%= camelizedModuleName %>([42]); assert.ok(result); }); diff --git a/blueprints/initializer-addon/index.js b/blueprints/initializer-addon/index.js index 913fb8d..270f28f 100644 --- a/blueprints/initializer-addon/index.js +++ b/blueprints/initializer-addon/index.js @@ -1,3 +1,3 @@ /*jshint node:true*/ -module.exports = require('ember-cli/blueprints/addon-import'); +module.exports = require('../-addon-import'); diff --git a/blueprints/initializer-test/index.js b/blueprints/initializer-test/index.js index b3460fc..dd48fc1 100644 --- a/blueprints/initializer-test/index.js +++ b/blueprints/initializer-test/index.js @@ -1,14 +1,15 @@ /*jshint node:true*/ -var getDependencyDepth = require('ember-cli-get-dependency-depth'); var testInfo = require('ember-cli-test-info'); +var stringUtils = require('ember-cli-string-utils'); +var useTestFrameworkDetector = require('../test-framework-detector'); -module.exports = { +module.exports = useTestFrameworkDetector({ description: 'Generates an initializer unit test.', locals: function(options) { return { - friendlyTestName: testInfo.name(options.entity.name, "Unit", "Initializer"), - dependencyDepth: getDependencyDepth(options.entity.name) + friendlyTestName: testInfo.name(options.entity.name, 'Unit', 'Initializer'), + dasherizedModulePrefix: stringUtils.dasherize(options.project.config().modulePrefix) }; } -}; +}); diff --git a/blueprints/initializer-test/mocha-files/tests/unit/initializers/__name__-test.js b/blueprints/initializer-test/mocha-files/tests/unit/initializers/__name__-test.js new file mode 100644 index 0000000..f73838b --- /dev/null +++ b/blueprints/initializer-test/mocha-files/tests/unit/initializers/__name__-test.js @@ -0,0 +1,24 @@ +/* jshint expr:true */ +import { expect } from 'chai'; +import { describe, it, beforeEach } from 'mocha'; +import Ember from 'ember'; +import <%= classifiedModuleName %>Initializer from '<%= dasherizedModulePrefix %>/initializers/<%= dasherizedModuleName %>'; + +describe('<%= friendlyTestName %>', function() { + let application; + + beforeEach(function() { + Ember.run(function() { + application = Ember.Application.create(); + application.deferReadiness(); + }); + }); + + // Replace this with your real tests. + it('works', function() { + <%= classifiedModuleName %>Initializer.initialize(application); + + // you would normally confirm the results of the initializer here + expect(true).to.be.ok; + }); +}); diff --git a/blueprints/initializer-test/files/tests/unit/initializers/__name__-test.js b/blueprints/initializer-test/qunit-files/tests/unit/initializers/__name__-test.js similarity index 63% rename from blueprints/initializer-test/files/tests/unit/initializers/__name__-test.js rename to blueprints/initializer-test/qunit-files/tests/unit/initializers/__name__-test.js index eab245b..b58aa2d 100644 --- a/blueprints/initializer-test/files/tests/unit/initializers/__name__-test.js +++ b/blueprints/initializer-test/qunit-files/tests/unit/initializers/__name__-test.js @@ -1,14 +1,13 @@ import Ember from 'ember'; -import { initialize } from '<%= dependencyDepth %>/initializers/<%= dasherizedModuleName %>'; +import <%= classifiedModuleName %>Initializer from '<%= dasherizedModulePrefix %>/initializers/<%= dasherizedModuleName %>'; import { module, test } from 'qunit'; -var registry, application; +let application; module('<%= friendlyTestName %>', { - beforeEach: function() { + beforeEach() { Ember.run(function() { application = Ember.Application.create(); - registry = application.registry; application.deferReadiness(); }); } @@ -16,7 +15,7 @@ module('<%= friendlyTestName %>', { // Replace this with your real tests. test('it works', function(assert) { - initialize(registry, application); + <%= classifiedModuleName %>Initializer.initialize(application); // you would normally confirm the results of the initializer here assert.ok(true); diff --git a/blueprints/initializer/files/__root__/initializers/__name__.js b/blueprints/initializer/files/__root__/initializers/__name__.js index 96de5a3..f47caae 100644 --- a/blueprints/initializer/files/__root__/initializers/__name__.js +++ b/blueprints/initializer/files/__root__/initializers/__name__.js @@ -1,8 +1,8 @@ -export function initialize(/* container, application */) { +export function initialize(/* application */) { // application.inject('route', 'foo', 'service:foo'); } export default { name: '<%= dasherizedModuleName %>', - initialize: initialize + initialize }; diff --git a/blueprints/instance-initializer-addon/files/__root__/__path__/__name__.js b/blueprints/instance-initializer-addon/files/__root__/__path__/__name__.js new file mode 100644 index 0000000..79e541a --- /dev/null +++ b/blueprints/instance-initializer-addon/files/__root__/__path__/__name__.js @@ -0,0 +1 @@ +export { default, initialize } from '<%= modulePath %>'; diff --git a/blueprints/instance-initializer-addon/index.js b/blueprints/instance-initializer-addon/index.js new file mode 100644 index 0000000..270f28f --- /dev/null +++ b/blueprints/instance-initializer-addon/index.js @@ -0,0 +1,3 @@ +/*jshint node:true*/ + +module.exports = require('../-addon-import'); diff --git a/blueprints/instance-initializer-test/index.js b/blueprints/instance-initializer-test/index.js new file mode 100644 index 0000000..f04393c --- /dev/null +++ b/blueprints/instance-initializer-test/index.js @@ -0,0 +1,15 @@ +/*jshint node:true*/ + +var testInfo = require('ember-cli-test-info'); +var stringUtils = require('ember-cli-string-utils'); +var useTestFrameworkDetector = require('../test-framework-detector'); + +module.exports = useTestFrameworkDetector({ + description: 'Generates an instance initializer unit test.', + locals: function(options) { + return { + friendlyTestName: testInfo.name(options.entity.name, 'Unit', 'Instance Initializer'), + dasherizedModulePrefix: stringUtils.dasherize(options.project.config().modulePrefix) + }; + } +}); diff --git a/blueprints/instance-initializer-test/mocha-files/tests/unit/instance-initializers/__name__-test.js b/blueprints/instance-initializer-test/mocha-files/tests/unit/instance-initializers/__name__-test.js new file mode 100644 index 0000000..06d80f0 --- /dev/null +++ b/blueprints/instance-initializer-test/mocha-files/tests/unit/instance-initializers/__name__-test.js @@ -0,0 +1,30 @@ +/* jshint expr:true */ +import { expect } from 'chai'; +import { describe, it, beforeEach } from 'mocha'; +import Ember from 'ember'; +import { initialize } from '<%= dasherizedModulePrefix %>/instance-initializers/<%= dasherizedModuleName %>'; +import destroyApp from '../../helpers/destroy-app'; + +describe('<%= friendlyTestName %>', function() { + let application, appInstance; + + beforeEach(function() { + Ember.run(function() { + application = Ember.Application.create(); + appInstance = application.buildInstance(); + }); + }); + + afterEach(function() { + Ember.run(appInstance, 'destroy'); + destroyApp(application); + }); + + // Replace this with your real tests. + it('works', function() { + initialize(appInstance); + + // you would normally confirm the results of the initializer here + expect(true).to.be.ok; + }); +}); diff --git a/blueprints/instance-initializer-test/qunit-files/tests/unit/instance-initializers/__name__-test.js b/blueprints/instance-initializer-test/qunit-files/tests/unit/instance-initializers/__name__-test.js new file mode 100644 index 0000000..ec252a8 --- /dev/null +++ b/blueprints/instance-initializer-test/qunit-files/tests/unit/instance-initializers/__name__-test.js @@ -0,0 +1,25 @@ +import Ember from 'ember'; +import { initialize } from '<%= dasherizedModulePrefix %>/instance-initializers/<%= dasherizedModuleName %>'; +import { module, test } from 'qunit'; +import destroyApp from '../../helpers/destroy-app'; + +module('<%= friendlyTestName %>', { + beforeEach: function() { + Ember.run(() => { + this.application = Ember.Application.create(); + this.appInstance = this.application.buildInstance(); + }); + }, + afterEach: function() { + Ember.run(this.appInstance, 'destroy'); + destroyApp(this.application); + } +}); + +// Replace this with your real tests. +test('it works', function(assert) { + initialize(this.appInstance); + + // you would normally confirm the results of the initializer here + assert.ok(true); +}); diff --git a/blueprints/instance-initializer/files/__root__/instance-initializers/__name__.js b/blueprints/instance-initializer/files/__root__/instance-initializers/__name__.js new file mode 100644 index 0000000..4b96d1b --- /dev/null +++ b/blueprints/instance-initializer/files/__root__/instance-initializers/__name__.js @@ -0,0 +1,8 @@ +export function initialize(/* appInstance */) { + // appInstance.inject('route', 'foo', 'service:foo'); +} + +export default { + name: '<%= dasherizedModuleName %>', + initialize +}; diff --git a/blueprints/instance-initializer/index.js b/blueprints/instance-initializer/index.js new file mode 100644 index 0000000..96afb7f --- /dev/null +++ b/blueprints/instance-initializer/index.js @@ -0,0 +1,5 @@ +/*jshint node:true*/ + +module.exports = { + description: 'Generates an instance initializer.' +}; diff --git a/blueprints/mixin-test/index.js b/blueprints/mixin-test/index.js index 27ca2fd..f0fb375 100644 --- a/blueprints/mixin-test/index.js +++ b/blueprints/mixin-test/index.js @@ -1,12 +1,14 @@ /*jshint node:true*/ var testInfo = require('ember-cli-test-info'); +var useTestFrameworkDetector = require('../test-framework-detector'); -module.exports = { +module.exports = useTestFrameworkDetector({ description: 'Generates a mixin unit test.', locals: function(options) { return { + projectName: options.inRepoAddon ? options.inRepoAddon : options.project.name(), friendlyTestName: testInfo.name(options.entity.name, 'Unit', 'Mixin') }; } -}; +}); diff --git a/blueprints/mixin-test/mocha-files/tests/unit/mixins/__name__-test.js b/blueprints/mixin-test/mocha-files/tests/unit/mixins/__name__-test.js new file mode 100644 index 0000000..b59ffd0 --- /dev/null +++ b/blueprints/mixin-test/mocha-files/tests/unit/mixins/__name__-test.js @@ -0,0 +1,14 @@ +/* jshint expr:true */ +import { expect } from 'chai'; +import { describe, it } from 'mocha'; +import Ember from 'ember'; +import <%= classifiedModuleName %>Mixin from '<%= dasherizedPackageName %>/mixins/<%= dasherizedModuleName %>'; + +describe('<%= friendlyTestName %>', function() { + // Replace this with your real tests. + it('works', function() { + let <%= classifiedModuleName %>Object = Ember.Object.extend(<%= classifiedModuleName %>Mixin); + let subject = <%= classifiedModuleName %>Object.create(); + expect(subject).to.be.ok; + }); +}); diff --git a/blueprints/mixin-test/files/tests/unit/mixins/__name__-test.js b/blueprints/mixin-test/qunit-files/tests/unit/mixins/__name__-test.js similarity index 50% rename from blueprints/mixin-test/files/tests/unit/mixins/__name__-test.js rename to blueprints/mixin-test/qunit-files/tests/unit/mixins/__name__-test.js index 5f6e124..72d60b1 100644 --- a/blueprints/mixin-test/files/tests/unit/mixins/__name__-test.js +++ b/blueprints/mixin-test/qunit-files/tests/unit/mixins/__name__-test.js @@ -1,12 +1,12 @@ import Ember from 'ember'; -import <%= classifiedModuleName %>Mixin from '../../../mixins/<%= dasherizedModuleName %>'; +import <%= classifiedModuleName %>Mixin from '<%= projectName %>/mixins/<%= dasherizedModuleName %>'; import { module, test } from 'qunit'; module('<%= friendlyTestName %>'); // Replace this with your real tests. test('it works', function(assert) { - var <%= classifiedModuleName %>Object = Ember.Object.extend(<%= classifiedModuleName %>Mixin); - var subject = <%= classifiedModuleName %>Object.create(); + let <%= classifiedModuleName %>Object = Ember.Object.extend(<%= classifiedModuleName %>Mixin); + let subject = <%= classifiedModuleName %>Object.create(); assert.ok(subject); }); diff --git a/blueprints/route-addon/index.js b/blueprints/route-addon/index.js index cc2d44b..3c90207 100644 --- a/blueprints/route-addon/index.js +++ b/blueprints/route-addon/index.js @@ -29,13 +29,11 @@ module.exports = { return options.dasherizedModuleName; }, __path__: function(options) { - var blueprintName = options.originBlueprintName; - if (options.pod && options.hasPathToken) { return path.join(options.podPath, options.dasherizedModuleName); } - return inflector.pluralize(blueprintName); + return 'routes'; }, __root__: function(options) { if (options.inRepoAddon) { diff --git a/blueprints/route-test/index.js b/blueprints/route-test/index.js index 79258af..ef4d986 100644 --- a/blueprints/route-test/index.js +++ b/blueprints/route-test/index.js @@ -1,12 +1,13 @@ /*jshint node:true*/ var testInfo = require('ember-cli-test-info'); +var useTestFrameworkDetector = require('../test-framework-detector'); -module.exports = { +module.exports = useTestFrameworkDetector({ description: 'Generates a route unit test.', locals: function(options) { return { - friendlyTestDescription: testInfo.description(options.entity.name, "Unit", "Route") + friendlyTestDescription: testInfo.description(options.entity.name, 'Unit', 'Route') }; }, -}; +}); diff --git a/blueprints/route-test/mocha-files/tests/unit/__path__/__test__.js b/blueprints/route-test/mocha-files/tests/unit/__path__/__test__.js new file mode 100644 index 0000000..54f8b9c --- /dev/null +++ b/blueprints/route-test/mocha-files/tests/unit/__path__/__test__.js @@ -0,0 +1,16 @@ +/* jshint expr:true */ +import { expect } from 'chai'; +import { describeModule, it } from 'ember-mocha'; + +describeModule('route:<%= dasherizedModuleName %>', '<%= friendlyTestDescription %>', + { + // Specify the other units that are required for this test. + // needs: ['controller:foo'] + }, + function() { + it('exists', function() { + let route = this.subject(); + expect(route).to.be.ok; + }); + } +); diff --git a/blueprints/route-test/files/tests/unit/__path__/__test__.js b/blueprints/route-test/qunit-files/tests/unit/__path__/__test__.js similarity index 90% rename from blueprints/route-test/files/tests/unit/__path__/__test__.js rename to blueprints/route-test/qunit-files/tests/unit/__path__/__test__.js index 4099e6f..45dc244 100644 --- a/blueprints/route-test/files/tests/unit/__path__/__test__.js +++ b/blueprints/route-test/qunit-files/tests/unit/__path__/__test__.js @@ -6,6 +6,6 @@ moduleFor('route:<%= dasherizedModuleName %>', '<%= friendlyTestDescription %>', }); test('it exists', function(assert) { - var route = this.subject(); + let route = this.subject(); assert.ok(route); }); diff --git a/blueprints/route/index.js b/blueprints/route/index.js index 9d89e73..d1b1f54 100644 --- a/blueprints/route/index.js +++ b/blueprints/route/index.js @@ -6,7 +6,7 @@ var chalk = require('chalk'); var EmberRouterGenerator = require('ember-router-generator'); module.exports = { - description: 'Generates a route and registers it with the router.', + description: 'Generates a route and a template, and registers the route with the router.', availableOptions: [ { @@ -18,6 +18,10 @@ module.exports = { name: 'skip-router', type: Boolean, default: false + }, + { + name: 'reset-namespace', + type: Boolean } ], diff --git a/blueprints/service-test/index.js b/blueprints/service-test/index.js index 0e9b734..ca0a590 100644 --- a/blueprints/service-test/index.js +++ b/blueprints/service-test/index.js @@ -1,12 +1,13 @@ /*jshint node:true*/ var testInfo = require('ember-cli-test-info'); +var useTestFrameworkDetector = require('../test-framework-detector'); -module.exports = { +module.exports = useTestFrameworkDetector({ description: 'Generates a service unit test.', locals: function(options) { return { - friendlyTestDescription: testInfo.description(options.entity.name, "Unit", "Service") + friendlyTestDescription: testInfo.description(options.entity.name, 'Unit', 'Service') }; }, -}; +}); diff --git a/blueprints/service-test/mocha-files/tests/unit/__path__/__name__-test.js b/blueprints/service-test/mocha-files/tests/unit/__path__/__name__-test.js new file mode 100644 index 0000000..ddc2d6a --- /dev/null +++ b/blueprints/service-test/mocha-files/tests/unit/__path__/__name__-test.js @@ -0,0 +1,17 @@ +/* jshint expr:true */ +import { expect } from 'chai'; +import { describeModule, it } from 'ember-mocha'; + +describeModule('service:<%= dasherizedModuleName %>', '<%= friendlyTestDescription %>', + { + // Specify the other units that are required for this test. + // needs: ['service:foo'] + }, + function() { + // Replace this with your real tests. + it('exists', function() { + let service = this.subject(); + expect(service).to.be.ok; + }); + } +); diff --git a/blueprints/service-test/files/tests/unit/__path__/__test__.js b/blueprints/service-test/qunit-files/tests/unit/__path__/__test__.js similarity index 91% rename from blueprints/service-test/files/tests/unit/__path__/__test__.js rename to blueprints/service-test/qunit-files/tests/unit/__path__/__test__.js index ad0b0c9..94db075 100644 --- a/blueprints/service-test/files/tests/unit/__path__/__test__.js +++ b/blueprints/service-test/qunit-files/tests/unit/__path__/__test__.js @@ -7,6 +7,6 @@ moduleFor('service:<%= dasherizedModuleName %>', '<%= friendlyTestDescription %> // Replace this with your real tests. test('it exists', function(assert) { - var service = this.subject(); + let service = this.subject(); assert.ok(service); }); diff --git a/blueprints/util-test/index.js b/blueprints/util-test/index.js index d023d66..99248d6 100644 --- a/blueprints/util-test/index.js +++ b/blueprints/util-test/index.js @@ -1,12 +1,15 @@ /*jshint node:true*/ -var testInfo = require('ember-cli-test-info'); +var testInfo = require('ember-cli-test-info'); +var stringUtils = require('ember-cli-string-utils'); +var useTestFrameworkDetector = require('../test-framework-detector'); -module.exports = { +module.exports = useTestFrameworkDetector({ description: 'Generates a util unit test.', locals: function(options) { return { - friendlyTestName: testInfo.name(options.entity.name, "Unit", "Utility") + friendlyTestName: testInfo.name(options.entity.name, 'Unit', 'Utility'), + dasherizedModulePrefix: stringUtils.dasherize(options.project.config().modulePrefix) }; } -}; +}); diff --git a/blueprints/util-test/mocha-files/tests/unit/utils/__name__-test.js b/blueprints/util-test/mocha-files/tests/unit/utils/__name__-test.js new file mode 100644 index 0000000..558f0fa --- /dev/null +++ b/blueprints/util-test/mocha-files/tests/unit/utils/__name__-test.js @@ -0,0 +1,12 @@ +/* jshint expr:true */ +import { expect } from 'chai'; +import { describe, it } from 'mocha'; +import <%= camelizedModuleName %> from '<%= dasherizedPackageName %>/utils/<%= dasherizedModuleName %>'; + +describe('<%= friendlyTestName %>', function() { + // Replace this with your real tests. + it('works', function() { + let result = <%= camelizedModuleName %>(); + expect(result).to.be.ok; + }); +}); diff --git a/blueprints/util-test/files/tests/unit/utils/__name__-test.js b/blueprints/util-test/qunit-files/tests/unit/utils/__name__-test.js similarity index 53% rename from blueprints/util-test/files/tests/unit/utils/__name__-test.js rename to blueprints/util-test/qunit-files/tests/unit/utils/__name__-test.js index 0df8f6b..287fb46 100644 --- a/blueprints/util-test/files/tests/unit/utils/__name__-test.js +++ b/blueprints/util-test/qunit-files/tests/unit/utils/__name__-test.js @@ -1,10 +1,10 @@ -import <%= camelizedModuleName %> from '../../../utils/<%= dasherizedModuleName %>'; +import <%= camelizedModuleName %> from '<%= dasherizedModulePrefix %>/utils/<%= dasherizedModuleName %>'; import { module, test } from 'qunit'; module('<%= friendlyTestName %>'); // Replace this with your real tests. test('it works', function(assert) { - var result = <%= camelizedModuleName %>(); + let result = <%= camelizedModuleName %>(); assert.ok(result); }); diff --git a/node-tests/blueprints/acceptance-test-test.js b/node-tests/blueprints/acceptance-test-test.js new file mode 100644 index 0000000..d2efd7a --- /dev/null +++ b/node-tests/blueprints/acceptance-test-test.js @@ -0,0 +1,98 @@ +'use strict'; + +var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup'); +var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper'); +var generateAndDestroy = BlueprintHelpers.generateAndDestroy; + +describe('Acceptance: ember generate and destroy acceptance-test', function() { + setupTestHooks(this); + + it('acceptance-test foo', function() { + // pass any additional command line options in the arguments array + return generateAndDestroy(['acceptance-test', 'foo'], { + files: [ + { + file: 'tests/acceptance/foo-test.js', + contains: [ + "import { test } from 'qunit';", + "moduleForAcceptance('Acceptance | foo');", + "test('visiting /foo', function(assert) {", + "visit('/foo');", + "andThen(function() {", + "assert.equal(currentURL(), '/foo');" + ] + } + ] + }); + }); + + it('in-addon acceptance-test foo', function() { + return generateAndDestroy(['acceptance-test', 'foo'], { + target: 'addon', + files: [ + { + file: 'tests/acceptance/foo-test.js', + contains: [ + "import { test } from 'qunit';", + "moduleForAcceptance('Acceptance | foo');", + "test('visiting /foo', function(assert) {", + "visit('/foo');", + "andThen(function() {", + "assert.equal(currentURL(), '/foo');" + ] + }, + { + file: 'app/acceptance-tests/foo.js', + exists: false + } + ] + }); + }); + + it('in-addon acceptance-test foo/bar', function() { + return generateAndDestroy(['acceptance-test', 'foo/bar'], { + target: 'addon', + files: [ + { + file: 'tests/acceptance/foo/bar-test.js', + contains: [ + "import { test } from 'qunit';", + "moduleForAcceptance('Acceptance | foo/bar');", + "test('visiting /foo/bar', function(assert) {", + "visit('/foo/bar');", + "andThen(function() {", + "assert.equal(currentURL(), '/foo/bar');" + ] + }, + { + file: 'app/acceptance-tests/foo/bar.js', + exists: false + } + ] + }); + }); + + it('acceptance-test foo for mocha', function() { + // pass any additional command line options in the arguments array + return generateAndDestroy(['acceptance-test', 'foo'], { + packages: [ + { name: 'ember-cli-qunit', delete: true }, + { name: 'ember-cli-mocha', dev: true } + ], + files: [ + { + file: 'tests/acceptance/foo-test.js', + contains: [ + "import { describe, it, beforeEach, afterEach } from 'mocha';", + "import { expect } from 'chai';", + "describe('Acceptance | foo', function() {", + "it('can visit /foo', function() {", + "visit('/foo');", + "andThen(function() {", + "expect(currentURL()).to.equal('/foo');" + ] + } + ] + }); + }); +}); diff --git a/node-tests/blueprints/component-addon-test.js b/node-tests/blueprints/component-addon-test.js new file mode 100644 index 0000000..447717b --- /dev/null +++ b/node-tests/blueprints/component-addon-test.js @@ -0,0 +1,23 @@ +'use strict'; + +var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup'); +var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper'); +var generateAndDestroy = BlueprintHelpers.generateAndDestroy; + +describe('Acceptance: ember generate and destroy component-addon', function() { + setupTestHooks(this); + + it('component-addon foo-bar', function() { + // pass any additional command line options in the arguments array + return generateAndDestroy(['component-addon', 'foo-bar'], { + target: 'addon', + // define files to assert, and their contents + files: [ + { + file: 'app/components/foo-bar.js', + contents: "export { default } from 'my-addon/components/foo-bar';" + } + ] + }); + }); +}); diff --git a/node-tests/blueprints/component-test.js b/node-tests/blueprints/component-test.js new file mode 100644 index 0000000..f2dd96e --- /dev/null +++ b/node-tests/blueprints/component-test.js @@ -0,0 +1,1077 @@ +'use strict'; + +var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup'); +var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper'); +var generateAndDestroy = BlueprintHelpers.generateAndDestroy; + +describe('Acceptance: ember generate component', function() { + setupTestHooks(this); + + it('component x-foo', function() { + return generateAndDestroy(['component', 'x-foo'], { + files:[ + { + file: 'app/components/x-foo.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Component.extend({", + "});" + ] + }, + { + file: 'app/templates/components/x-foo.hbs', + contains: "{{yield}}" + }, + { + file: 'tests/integration/components/x-foo-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "import hbs from 'htmlbars-inline-precompile';", + "moduleForComponent('x-foo'", + "integration: true", + "{{x-foo}}", + "{{#x-foo}}" + ] + } + ] + }); + }); + + it('component foo/x-foo', function() { + return generateAndDestroy(['component', 'foo/x-foo'], { + files: [ + { + file: 'app/components/foo/x-foo.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Component.extend({", + "});" + ] + }, + { + file: 'app/templates/components/foo/x-foo.hbs', + contains: "{{yield}}" + }, + { + file: 'tests/integration/components/foo/x-foo-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "import hbs from 'htmlbars-inline-precompile';", + "moduleForComponent('foo/x-foo'", + "integration: true", + "{{foo/x-foo}}", + "{{#foo/x-foo}}" + ] + } + ] + }); + }); + + it('component x-foo ignores --path option', function() { + return generateAndDestroy(['component', 'x-foo', '--path', 'foo'], { + files: [ + { + file: 'app/components/x-foo.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Component.extend({", + "});" + ] + }, + { + file: 'app/templates/components/x-foo.hbs', + contains: "{{yield}}" + }, + { + file: 'tests/integration/components/x-foo-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "import hbs from 'htmlbars-inline-precompile';", + "moduleForComponent('x-foo'", + "integration: true", + "{{x-foo}}", + "{{#x-foo}}" + ] + } + ] + }); + }); + + it('in-addon component x-foo', function() { + return generateAndDestroy(['component', 'x-foo'], { + target: 'addon', + files: [ + { + file:'addon/components/x-foo.js', + contains: [ + "import Ember from 'ember';", + "import layout from '../templates/components/x-foo';", + "export default Ember.Component.extend({", + "layout", + "});" + ] + }, + { + file:'addon/templates/components/x-foo.hbs', + contains: "{{yield}}" + }, + { + file:'app/components/x-foo.js', + contains: [ + "export { default } from 'my-addon/components/x-foo';" + ] + }, + { + file:'tests/integration/components/x-foo-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "import hbs from 'htmlbars-inline-precompile';", + "moduleForComponent('x-foo'", + "integration: true", + "{{x-foo}}", + "{{#x-foo}}" + ] + } + ] + }); + }); + + it('in-addon component nested/x-foo', function() { + return generateAndDestroy(['component', 'nested/x-foo'], { + target: 'addon', + files: [ + { + file:'addon/components/nested/x-foo.js', + contains: [ + "import Ember from 'ember';", + "import layout from '../../templates/components/nested/x-foo';", + "export default Ember.Component.extend({", + "layout", + "});" + ] + }, + { + file:'addon/templates/components/nested/x-foo.hbs', + contains: "{{yield}}" + }, + { + file:'app/components/nested/x-foo.js', + contains: [ + "export { default } from 'my-addon/components/nested/x-foo';" + ] + }, + { + file:'tests/integration/components/nested/x-foo-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "import hbs from 'htmlbars-inline-precompile';", + "moduleForComponent('nested/x-foo'", + "integration: true", + "{{nested/x-foo}}", + "{{#nested/x-foo}}" + ] + } + ] + }); + }); + + it('dummy component x-foo', function() { + return generateAndDestroy(['component', 'x-foo', '--dummy'], { + target: 'addon', + files: [ + { + file: 'tests/dummy/app/components/x-foo.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Component.extend({", + "});" + ] + }, + { + file: 'tests/dummy/app/templates/components/x-foo.hbs', + contains: "{{yield}}" + }, + { + file: 'app/components/x-foo.js', + exists: false + }, + { + file: 'tests/unit/components/x-foo-test.js', + exists: false + } + ] + }); + }); + + it('dummy component nested/x-foo', function() { + return generateAndDestroy(['component', 'nested/x-foo', '--dummy'], { + target: 'addon', + files: [ + { + file: 'tests/dummy/app/components/nested/x-foo.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Component.extend({", + "});" + ] + }, + { + file: 'tests/dummy/app/templates/components/nested/x-foo.hbs', + contains: "{{yield}}" + }, + { + file: 'app/components/nested/x-foo.js', + exists: false + }, + { + file: 'tests/unit/components/nested/x-foo-test.js', + exists: false + } + ] + }); + }); + + it('in-repo-addon component x-foo', function() { + return generateAndDestroy(['component', 'x-foo', '--in-repo-addon=my-addon'], { + target: 'inRepoAddon', + files: [ + { + file: 'lib/my-addon/addon/components/x-foo.js', + contains: [ + "import Ember from 'ember';", + "import layout from '../templates/components/x-foo';", + "export default Ember.Component.extend({", + "layout", + "});" + ] + }, + { + file: 'lib/my-addon/addon/templates/components/x-foo.hbs', + contains: "{{yield}}" + }, + { + file: 'lib/my-addon/app/components/x-foo.js', + contains: [ + "export { default } from 'my-addon/components/x-foo';" + ] + }, + { + file: 'tests/integration/components/x-foo-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "import hbs from 'htmlbars-inline-precompile';", + "moduleForComponent('x-foo'", + "integration: true", + "{{x-foo}}", + "{{#x-foo}}" + ] + } + ] + }); + }); + + it('in-repo-addon component-test x-foo', function() { + return generateAndDestroy(['component-test', 'x-foo', '--in-repo-addon=my-addon'], { + target: 'inRepoAddon', + files: [ + { + file: 'tests/integration/components/x-foo-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "import hbs from 'htmlbars-inline-precompile';", + "moduleForComponent('x-foo'", + "integration: true", + "{{x-foo}}", + "{{#x-foo}}" + ] + } + ] + }); + }); + + it('in-repo-addon component-test x-foo --unit', function() { + return generateAndDestroy(['component-test', 'x-foo', '--in-repo-addon=my-addon', '--unit'], { + target: 'inRepoAddon', + files: [ + { + file: 'tests/unit/components/x-foo-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "moduleForComponent('x-foo'", + "unit: true" + ] + } + ] + }); + }); + + it('in-repo-addon component nested/x-foo', function() { + return generateAndDestroy(['component', 'nested/x-foo', '--in-repo-addon=my-addon'], { + target: 'inRepoAddon', + files: [ + { + file: 'lib/my-addon/addon/components/nested/x-foo.js', + contains: [ + "import Ember from 'ember';", + "import layout from '../../templates/components/nested/x-foo';", + "export default Ember.Component.extend({", + "layout", + "});" + ] + }, + { + file: 'lib/my-addon/addon/templates/components/nested/x-foo.hbs', + contains: "{{yield}}" + }, + { + file: 'lib/my-addon/app/components/nested/x-foo.js', + contains: [ + "export { default } from 'my-addon/components/nested/x-foo';" + ] + }, + { + file: 'tests/integration/components/nested/x-foo-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "import hbs from 'htmlbars-inline-precompile';", + "moduleForComponent('nested/x-foo'", + "integration: true" + ] + } + ] + }); + }); +/** +* Pod tests +* +*/ + it('component x-foo --pod', function() { + return generateAndDestroy(['component', 'x-foo', '--pod'], { + files: [ + { + file: 'app/components/x-foo/component.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Component.extend({", + "});" + ] + }, + { + file: 'app/components/x-foo/template.hbs', + contains: "{{yield}}" + }, + { + file: 'tests/integration/components/x-foo/component-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "import hbs from 'htmlbars-inline-precompile';", + "moduleForComponent('x-foo'", + "integration: true" + ] + }, + ] + }); + }); + + it('component x-foo --pod podModulePrefix', function() { + return generateAndDestroy(['component', 'x-foo', '--pod'], { + podModulePrefix: true, + files: [ + { + file: 'app/pods/components/x-foo/component.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Component.extend({", + "});" + ] + }, + { + file: 'app/pods/components/x-foo/template.hbs', + contains: "{{yield}}" + }, + { + file: 'tests/integration/pods/components/x-foo/component-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "import hbs from 'htmlbars-inline-precompile';", + "moduleForComponent('x-foo'", + "integration: true", + "{{x-foo}}", + "{{#x-foo}}" + ] + }, + ] + }); + }); + + it('component foo/x-foo --pod', function() { + return generateAndDestroy(['component', 'foo/x-foo', '--pod'], { + files: [ + { + file: 'app/components/foo/x-foo/component.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Component.extend({", + "});" + ] + }, + { + file: 'app/components/foo/x-foo/template.hbs', + contains: "{{yield}}" + }, + { + file: 'tests/integration/components/foo/x-foo/component-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "import hbs from 'htmlbars-inline-precompile';", + "moduleForComponent('foo/x-foo'", + "integration: true", + "{{foo/x-foo}}", + "{{#foo/x-foo}}" + ] + }, + ] + }); + }); + + it('component foo/x-foo --pod podModulePrefix', function() { + return generateAndDestroy(['component', 'foo/x-foo', '--pod'], { + podModulePrefix: true, + files: [ + { + file: 'app/pods/components/foo/x-foo/component.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Component.extend({", + "});" + ] + }, + { + file: 'app/pods/components/foo/x-foo/template.hbs', + contains: "{{yield}}" + }, + { + file: 'tests/integration/pods/components/foo/x-foo/component-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "import hbs from 'htmlbars-inline-precompile';", + "moduleForComponent('foo/x-foo'", + "integration: true", + "{{foo/x-foo}}", + "{{#foo/x-foo}}" + ] + }, + ] + }); + }); + + it('component x-foo --pod --path', function() { + return generateAndDestroy(['component', 'x-foo', '--pod', '--path', 'bar'], { + files: [ + { + file: 'app/bar/x-foo/component.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Component.extend({", + "});" + ] + }, + { + file: 'app/bar/x-foo/template.hbs', + contains: "{{yield}}" + }, + { + file: 'tests/integration/bar/x-foo/component-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "import hbs from 'htmlbars-inline-precompile';", + "moduleForComponent('bar/x-foo'", + "integration: true", + "{{bar/x-foo}}", + "{{#bar/x-foo}}" + ] + }, + ] + }); + }); + + it('component x-foo --pod --path podModulePrefix', function() { + return generateAndDestroy(['component', 'x-foo', '--pod', '--path', 'bar'], { + podModulePrefix: true, + files: [ + { + file: 'app/pods/bar/x-foo/component.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Component.extend({", + "});" + ] + }, + { + file: 'app/pods/bar/x-foo/template.hbs', + contains: "{{yield}}" + }, + { + file: 'tests/integration/pods/bar/x-foo/component-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "import hbs from 'htmlbars-inline-precompile';", + "moduleForComponent('bar/x-foo'", + "integration: true", + "{{bar/x-foo}}", + "{{#bar/x-foo}}" + ] + }, + ] + }); + }); + + it('component foo/x-foo --pod --path', function() { + return generateAndDestroy(['component', 'foo/x-foo', '--pod', '--path', 'bar'], { + files: [ + { + file: 'app/bar/foo/x-foo/component.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Component.extend({", + "});" + ] + }, + { + file: 'app/bar/foo/x-foo/template.hbs', + contains: "{{yield}}" + }, + { + file: 'tests/integration/bar/foo/x-foo/component-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "import hbs from 'htmlbars-inline-precompile';", + "moduleForComponent('bar/foo/x-foo'", + "integration: true", + "{{bar/foo/x-foo}}", + "{{#bar/foo/x-foo}}" + ] + }, + ] + }); + }); + + it('component foo/x-foo --pod --path podModulePrefix', function() { + return generateAndDestroy(['component', 'foo/x-foo', '--pod', '--path', 'bar'], { + podModulePrefix: true, + files: [ + { + file: 'app/pods/bar/foo/x-foo/component.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Component.extend({", + "});" + ] + }, + { + file: 'app/pods/bar/foo/x-foo/template.hbs', + contains: "{{yield}}" + }, + { + file: 'tests/integration/pods/bar/foo/x-foo/component-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "moduleForComponent('bar/foo/x-foo'", + "integration: true", + "{{bar/foo/x-foo}}", + "{{#bar/foo/x-foo}}" + ] + }, + ] + }); + }); + + it('component x-foo --pod --path nested', function() { + return generateAndDestroy(['component', 'x-foo', '--pod', '--path', 'bar/baz'], { + files: [ + { + file: 'app/bar/baz/x-foo/component.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Component.extend({", + "});" + ] + }, + { + file: 'app/bar/baz/x-foo/template.hbs', + contains: "{{yield}}" + }, + { + file: 'tests/integration/bar/baz/x-foo/component-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "import hbs from 'htmlbars-inline-precompile';", + "moduleForComponent('bar/baz/x-foo'", + "integration: true", + "{{bar/baz/x-foo}}", + "{{#bar/baz/x-foo}}" + ] + }, + ] + }); + }); + + it('component x-foo --pod --path nested podModulePrefix', function() { + return generateAndDestroy(['component', 'x-foo', '--pod', '--path', 'bar/baz'], { + podModulePrefix: true, + files: [ + { + file: 'app/pods/bar/baz/x-foo/component.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Component.extend({", + "});" + ] + }, + { + file: 'app/pods/bar/baz/x-foo/template.hbs', + contains: "{{yield}}" + }, + { + file: 'tests/integration/pods/bar/baz/x-foo/component-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "import hbs from 'htmlbars-inline-precompile';", + "moduleForComponent('bar/baz/x-foo'", + "integration: true", + "{{bar/baz/x-foo}}", + "{{#bar/baz/x-foo}}" + ] + }, + ] + }); + }); + + it('component foo/x-foo --pod --path nested', function() { + return generateAndDestroy(['component', 'foo/x-foo', '--pod', '--path', 'bar/baz'], { + files: [ + { + file: 'app/bar/baz/foo/x-foo/component.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Component.extend({", + "});" + ] + }, + { + file: 'app/bar/baz/foo/x-foo/template.hbs', + contains: "{{yield}}" + }, + { + file: 'tests/integration/bar/baz/foo/x-foo/component-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "import hbs from 'htmlbars-inline-precompile';", + "moduleForComponent('bar/baz/foo/x-foo'", + "integration: true", + "{{bar/baz/foo/x-foo}}", + "{{#bar/baz/foo/x-foo}}" + ] + }, + ] + }); + }); + + it('component foo/x-foo --pod --path nested podModulePrefix', function() { + return generateAndDestroy(['component', 'foo/x-foo', '--pod', '--path', 'bar/baz'], { + podModulePrefix: true, + files: [ + { + file: 'app/pods/bar/baz/foo/x-foo/component.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Component.extend({", + "});" + ] + }, + { + file: 'app/pods/bar/baz/foo/x-foo/template.hbs', + contains: "{{yield}}" + }, + { + file: 'tests/integration/pods/bar/baz/foo/x-foo/component-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "import hbs from 'htmlbars-inline-precompile';", + "moduleForComponent('bar/baz/foo/x-foo'", + "integration: true", + "{{bar/baz/foo/x-foo}}", + "{{#bar/baz/foo/x-foo}}" + ] + }, + ] + }); + }); + + it('component x-foo --pod -no-path', function() { + return generateAndDestroy(['component', 'x-foo', '--pod', '-no-path'], { + files: [ + { + file: 'app/x-foo/component.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Component.extend({", + "});" + ] + }, + { + file: 'app/x-foo/template.hbs', + contains: "{{yield}}" + }, + { + file: 'tests/integration/x-foo/component-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "import hbs from 'htmlbars-inline-precompile';", + "moduleForComponent('x-foo'", + "integration: true", + "{{x-foo}}", + "{{#x-foo}}" + ] + }, + ] + }); + }); + + it('component x-foo --pod -no-path podModulePrefix', function() { + return generateAndDestroy(['component', 'x-foo', '--pod', '-no-path'], { + podModulePrefix: true, + files: [ + { + file: 'app/pods/x-foo/component.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Component.extend({", + "});" + ] + }, + { + file: 'app/pods/x-foo/template.hbs', + contains: "{{yield}}" + }, + { + file: 'tests/integration/pods/x-foo/component-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "import hbs from 'htmlbars-inline-precompile';", + "moduleForComponent('x-foo'", + "integration: true", + "{{x-foo}}", + "{{#x-foo}}" + ] + }, + ] + }); + }); + + it('component foo/x-foo --pod -no-path', function() { + return generateAndDestroy(['component', 'foo/x-foo', '--pod', '-no-path'], { + files: [ + { + file: 'app/foo/x-foo/component.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Component.extend({", + "});" + ] + }, + { + file: 'app/foo/x-foo/template.hbs', + contains: "{{yield}}" + }, + { + file: 'tests/integration/foo/x-foo/component-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "import hbs from 'htmlbars-inline-precompile';", + "moduleForComponent('foo/x-foo'", + "integration: true", + "{{foo/x-foo}}", + "{{#foo/x-foo}}" + ] + }, + ] + }); + }); + + it('component foo/x-foo --pod -no-path podModulePrefix', function() { + return generateAndDestroy(['component', 'foo/x-foo', '--pod', '-no-path'], { + podModulePrefix: true, + files: [ + { + file: 'app/pods/foo/x-foo/component.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Component.extend({", + "});" + ] + }, + { + file: 'app/pods/foo/x-foo/template.hbs', + contains: "{{yield}}" + }, + { + file: 'tests/integration/pods/foo/x-foo/component-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "import hbs from 'htmlbars-inline-precompile';", + "moduleForComponent('foo/x-foo'", + "integration: true", + "{{foo/x-foo}}", + "{{#foo/x-foo}}" + ] + }, + ] + }); + }); + + it('in-addon component x-foo --pod', function() { + return generateAndDestroy(['component', 'x-foo', '--pod'], { + target: 'addon', + files: [ + { + file: 'addon/components/x-foo/component.js', + contains: [ + "import Ember from 'ember';", + "import layout from './template';", + "export default Ember.Component.extend({", + "layout", + "});" + ] + }, + { + file: 'addon/components/x-foo/template.hbs', + contains: "{{yield}}" + }, + { + file: 'app/components/x-foo/component.js', + contains: [ + "export { default } from 'my-addon/components/x-foo/component';" + ] + }, + { + file: 'tests/integration/components/x-foo/component-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "moduleForComponent('x-foo'", + "integration: true" + ] + } + ] + }); + }); + + it('in-repo-addon component x-foo --pod', function() { + return generateAndDestroy(['component', 'x-foo', '--in-repo-addon=my-addon', '--pod'], { + target: 'inRepoAddon', + files: [ + { + file: 'lib/my-addon/addon/components/x-foo/component.js', + contains: [ + "import Ember from 'ember';", + "import layout from './template';", + "export default Ember.Component.extend({", + "layout", + "});" + ] + }, + { + file: 'lib/my-addon/addon/components/x-foo/template.hbs', + contains: "{{yield}}" + }, + { + file: 'lib/my-addon/app/components/x-foo/component.js', + contains: [ + "export { default } from 'my-addon/components/x-foo/component';" + ] + }, + { + file: 'tests/integration/components/x-foo/component-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "moduleForComponent('x-foo'", + "integration: true" + ] + } + ] + }); + }); + + it('in-repo-addon component nested/x-foo', function() { + return generateAndDestroy(['component', 'nested/x-foo', '--in-repo-addon=my-addon', '--pod'], { + target: 'inRepoAddon', + files: [ + { + file: 'lib/my-addon/addon/components/nested/x-foo/component.js', + contains: [ + "import Ember from 'ember';", + "import layout from './template';", + "export default Ember.Component.extend({", + "layout", + "});" + ] + }, + { + file: 'lib/my-addon/addon/components/nested/x-foo/template.hbs', + contains: "{{yield}}" + }, + { + file: 'lib/my-addon/app/components/nested/x-foo/component.js', + contains: [ + "export { default } from 'my-addon/components/nested/x-foo/component';" + ] + }, + { + file: 'tests/integration/components/nested/x-foo/component-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "moduleForComponent('nested/x-foo'", + "integration: true" + ] + } + ] + }); + }); + + it('component-test x-foo', function() { + return generateAndDestroy(['component-test', 'x-foo'], { + files: [ + { + file: 'tests/integration/components/x-foo-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "import hbs from 'htmlbars-inline-precompile';", + "moduleForComponent('x-foo'", + "integration: true", + "{{x-foo}}", + "{{#x-foo}}" + ] + } + ] + }); + }); + + it('component-test x-foo --unit', function() { + return generateAndDestroy(['component-test', 'x-foo', '--unit'], { + files: [ + { + file: 'tests/unit/components/x-foo-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "moduleForComponent('x-foo'", + "unit: true" + ] + } + ] + }); + }); + + it('in-addon component-test x-foo', function() { + return generateAndDestroy(['component-test', 'x-foo'], { + target: 'addon', + files: [ + { + file:'tests/integration/components/x-foo-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "import hbs from 'htmlbars-inline-precompile';", + "moduleForComponent('x-foo'", + "integration: true", + "{{x-foo}}", + "{{#x-foo}}" + ] + }, + { + file: 'app/component-test/x-foo.js', + exists: false + } + ] + }); + }); + + it('in-addon component-test x-foo --unit', function() { + return generateAndDestroy(['component-test', 'x-foo', '--unit'], { + target: 'addon', + files: [ + { + file:'tests/unit/components/x-foo-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "moduleForComponent('x-foo'", + "unit: true" + ] + }, + { + file: 'app/component-test/x-foo.js', + exists: false + } + ] + }); + }); + + it('dummy component-test x-foo', function() { + return generateAndDestroy(['component-test', 'x-foo', '--dummy'], { + target: 'addon', + files: [ + { + file: 'tests/integration/components/x-foo-test.js', + contains: [ + "import { moduleForComponent, test } from 'ember-qunit';", + "import hbs from 'htmlbars-inline-precompile';", + "moduleForComponent('x-foo'" + ] + }, + { + file: 'app/component-test/x-foo.js', + exists: false + } + ] + }); + }); + + it('component-test x-foo for mocha', function() { + return generateAndDestroy(['component-test', 'x-foo'], { + packages: [ + { name: 'ember-cli-qunit', delete: true }, + { name: 'ember-cli-mocha', dev: true } + ], + files: [ + { + file: 'tests/integration/components/x-foo-test.js', + contains: [ + "import { describeComponent, it } from 'ember-mocha';", + "import hbs from 'htmlbars-inline-precompile';", + "describeComponent('x-foo', 'Integration | Component | x foo'", + "integration: true", + "{{x-foo}}", + "{{#x-foo}}" + ] + } + ] + }); + }); + + it('component-test x-foo --unit for mocha', function() { + return generateAndDestroy(['component-test', 'x-foo', '--unit'], { + packages: [ + { name: 'ember-cli-qunit', delete: true }, + { name: 'ember-cli-mocha', dev: true } + ], + files: [ + { + file: 'tests/unit/components/x-foo-test.js', + contains: [ + "import { describeComponent, it } from 'ember-mocha';", + "describeComponent('x-foo', 'Unit | Component | x foo", + "unit: true" + ] + } + ] + }); + }); +}); diff --git a/node-tests/blueprints/controller-test.js b/node-tests/blueprints/controller-test.js new file mode 100644 index 0000000..66a84b6 --- /dev/null +++ b/node-tests/blueprints/controller-test.js @@ -0,0 +1,346 @@ +'use strict'; + +var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup'); +var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper'); +var generateAndDestroy = BlueprintHelpers.generateAndDestroy; + +describe('Acceptance: ember generate and destroy controller', function() { + setupTestHooks(this); + + it('controller foo', function() { + return generateAndDestroy(['controller', 'foo'], { + files: [ + { + file: 'app/controllers/foo.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Controller.extend({\n});" + ] + }, + { + file: 'tests/unit/controllers/foo-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('controller:foo'" + ] + }, + ] + }); + }); + + it('controller foo/bar', function() { + return generateAndDestroy(['controller', 'foo/bar'], { + files: [ + { + file: 'app/controllers/foo/bar.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Controller.extend({\n});" + ] + }, + { + file: 'tests/unit/controllers/foo/bar-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('controller:foo/bar'" + ] + } + ] + }); + }); + + it('in-addon controller foo', function() { + return generateAndDestroy(['controller', 'foo'], { + target: 'addon', + files: [ + { + file: 'addon/controllers/foo.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Controller.extend({\n});" + ] + }, + { + file: 'app/controllers/foo.js', + contains: [ + "export { default } from 'my-addon/controllers/foo';" + ] + }, + { + file: 'tests/unit/controllers/foo-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('controller:foo'" + ] + } + ] + }); + }); + + it('in-addon controller foo/bar', function() { + return generateAndDestroy(['controller', 'foo/bar'], { + target: 'addon', + files: [ + { + file: 'addon/controllers/foo/bar.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Controller.extend({\n});" + ] + }, + { + file: 'app/controllers/foo/bar.js', + contains: [ + "export { default } from 'my-addon/controllers/foo/bar';" + ] + }, + { + file: 'tests/unit/controllers/foo/bar-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('controller:foo/bar'" + ] + } + ] + }); + }); + + it('dummy controller foo', function() { + return generateAndDestroy(['controller', 'foo', '--dummy'], { + target: 'addon', + files: [ + { + file: 'tests/dummy/app/controllers/foo.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Controller.extend({\n});" + ] + }, + { + file: 'app/controllers/foo-test.js', + exists: false + }, + { + file: 'tests/unit/controllers/foo-test.js', + exists: false + } + ] + }); + }); + + it('dummy controller foo/bar', function() { + return generateAndDestroy(['controller', 'foo/bar', '--dummy'], { + target: 'addon', + files: [ + { + file: 'tests/dummy/app/controllers/foo/bar.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Controller.extend({\n});" + ] + }, + { + file: 'app/controllers/foo/bar.js', + exists: false + }, + { + file: 'tests/unit/controllers/foo/bar-test.js', + exists: false + } + ] + }); + }); + + it('in-repo-addon controller foo', function() { + return generateAndDestroy(['controller', 'foo', '--in-repo-addon=my-addon'], { + target: 'inRepoAddon', + files: [ + { + file: 'lib/my-addon/addon/controllers/foo.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Controller.extend({\n});" + ] + }, + { + file: 'lib/my-addon/app/controllers/foo.js', + contains: [ + "export { default } from 'my-addon/controllers/foo';" + ] + }, + { + file: 'tests/unit/controllers/foo-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('controller:foo'" + ] + } + ] + }); + }); + + it('in-repo-addon controller foo/bar', function() { + return generateAndDestroy(['controller', 'foo/bar', '--in-repo-addon=my-addon'], { + target: 'inRepoAddon', + files: [ + { + file: 'lib/my-addon/addon/controllers/foo/bar.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Controller.extend({\n});" + ] + }, + { + file: 'lib/my-addon/app/controllers/foo/bar.js', + contains: [ + "export { default } from 'my-addon/controllers/foo/bar';" + ] + }, + { + file: 'tests/unit/controllers/foo/bar-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('controller:foo/bar'" + ] + } + ] + }); + }); + +/** +* Pod tests +* +*/ + it('controller foo --pod', function() { + return generateAndDestroy(['controller', 'foo', '--pod'], { + files: [ + { + file: 'app/foo/controller.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Controller.extend({\n});" + ] + }, + { + file: 'tests/unit/foo/controller-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('controller:foo'" + ] + } + ] + }); + }); + + it('controller foo --pod podModulePrefix', function() { + return generateAndDestroy(['controller', 'foo', '--pod'], { + podModulePrefix: true, + files: [ + { + file: 'app/pods/foo/controller.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Controller.extend({\n});" + ] + }, + { + file: 'tests/unit/pods/foo/controller-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('controller:foo'" + ] + } + ] + }); + }); + + it('controller foo/bar --pod', function() { + return generateAndDestroy(['controller', 'foo/bar', '--pod'], { + files: [ + { + file: 'app/foo/bar/controller.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Controller.extend({\n});" + ] + }, + { + file: 'tests/unit/foo/bar/controller-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('controller:foo/bar'" + ] + } + ] + }); + }); + + it('controller foo/bar --pod podModulePrefix', function() { + return generateAndDestroy(['controller', 'foo/bar', '--pod'], { + podModulePrefix: true, + files: [ + { + file: 'app/pods/foo/bar/controller.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Controller.extend({\n});" + ] + }, + { + file: 'tests/unit/pods/foo/bar/controller-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('controller:foo/bar'" + ] + } + ] + }); + }); + + it('controller-test foo', function() { + return generateAndDestroy(['controller-test', 'foo'], { + files: [ + { + file: 'tests/unit/controllers/foo-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('controller:foo'" + ] + }, + ] + }); + }); + + it('in-addon controller-test foo', function() { + return generateAndDestroy(['controller-test', 'foo'], { + target: 'addon', + files: [ + { + file: 'tests/unit/controllers/foo-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('controller:foo'" + ] + } + ] + }); + }); + + it('controller-test foo for mocha', function() { + return generateAndDestroy(['controller-test', 'foo'], { + packages: [ + { name: 'ember-cli-qunit', delete: true }, + { name: 'ember-cli-mocha', dev: true } + ], + files: [ + { + file: 'tests/unit/controllers/foo-test.js', + contains: [ + "import { describeModule, it } from 'ember-mocha';", + "describeModule('controller:foo', 'Unit | Controller | foo'" + ] + } + ] + }); + }); +}); diff --git a/node-tests/blueprints/helper-addon-test.js b/node-tests/blueprints/helper-addon-test.js new file mode 100644 index 0000000..bf8a29e --- /dev/null +++ b/node-tests/blueprints/helper-addon-test.js @@ -0,0 +1,24 @@ +'use strict'; + +var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup'); +var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper'); +var generateAndDestroy = BlueprintHelpers.generateAndDestroy; + +describe('Acceptance: ember generate and destroy helper-addon', function() { + setupTestHooks(this); + + it('in-addon helper-addon foo-bar', function() { + return generateAndDestroy(['helper-addon', 'foo-bar'], { + target: 'addon', + files: [ + { + file: 'app/helpers/foo-bar.js', + contains: [ + "export { default, fooBar } from 'my-addon/helpers/foo-bar';" + ] + }, + ] + }); + }); + +}); diff --git a/node-tests/blueprints/helper-test.js b/node-tests/blueprints/helper-test.js new file mode 100644 index 0000000..f639113 --- /dev/null +++ b/node-tests/blueprints/helper-test.js @@ -0,0 +1,304 @@ +'use strict'; + +var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup'); +var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper'); +var generateAndDestroy = BlueprintHelpers.generateAndDestroy; + +describe('Acceptance: ember generate and destroy helper', function() { + setupTestHooks(this); + + it('helper foo/bar-baz', function() { + return generateAndDestroy(['helper', 'foo/bar-baz'], { + files: [ + { + file: 'app/helpers/foo/bar-baz.js', + contains: "import Ember from 'ember';\n\n" + + "export function fooBarBaz(params/*, hash*/) {\n" + + " return params;\n" + + "}\n\n" + + "export default Ember.Helper.helper(fooBarBaz);" + }, + { + file: 'tests/unit/helpers/foo/bar-baz-test.js', + contains: "import { fooBarBaz } from 'my-app/helpers/foo/bar-baz';" + } + ] + }); + }); + + it('in-addon helper foo-bar', function() { + return generateAndDestroy(['helper', 'foo-bar'], { + target: 'addon', + files: [ + { + file: 'addon/helpers/foo-bar.js', + contains: "import Ember from 'ember';\n\n" + + "export function fooBar(params/*, hash*/) {\n" + + " return params;\n" + + "}\n\n" + + "export default Ember.Helper.helper(fooBar);" + }, + { + file: 'app/helpers/foo-bar.js', + contains: [ + "export { default, fooBar } from 'my-addon/helpers/foo-bar';" + ] + }, + { + file: 'tests/unit/helpers/foo-bar-test.js', + contains: "import { fooBar } from 'dummy/helpers/foo-bar';" + } + ] + }); + }); + + it('in-addon helper foo/bar-baz', function() { + return generateAndDestroy(['helper', 'foo/bar-baz'], { + target: 'addon', + files: [ + { + file: 'addon/helpers/foo/bar-baz.js', + contains: "import Ember from 'ember';\n\n" + + "export function fooBarBaz(params/*, hash*/) {\n" + + " return params;\n" + + "}\n\n" + + "export default Ember.Helper.helper(fooBarBaz);" + }, + { + file: 'app/helpers/foo/bar-baz.js', + contains: [ + "export { default, fooBarBaz } from 'my-addon/helpers/foo/bar-baz';" + ] + }, + { + file: 'tests/unit/helpers/foo/bar-baz-test.js', + contains: "import { fooBarBaz } from 'dummy/helpers/foo/bar-baz';" + } + ] + }); + }); + + it('dummy helper foo-bar', function() { + return generateAndDestroy(['helper', 'foo-bar', '--dummy'], { + target: 'addon', + files: [ + { + file: 'tests/dummy/app/helpers/foo-bar.js', + contains: "import Ember from 'ember';\n\n" + + "export function fooBar(params/*, hash*/) {\n" + + " return params;\n" + + "}\n\n" + + "export default Ember.Helper.helper(fooBar);" + }, + { + file: 'app/helpers/foo-bar.js', + exists: false + }, + { + file: 'tests/unit/helpers/foo-bar-test.js', + exists: false + } + ] + }); + }); + + it('dummy helper foo/bar-baz', function() { + return generateAndDestroy(['helper', 'foo/bar-baz', '--dummy'], { + target: 'addon', + files: [ + { + file: 'tests/dummy/app/helpers/foo/bar-baz.js', + contains: "import Ember from 'ember';\n\n" + + "export function fooBarBaz(params/*, hash*/) {\n" + + " return params;\n" + + "}\n\n" + + "export default Ember.Helper.helper(fooBarBaz);" + }, + { + file: 'app/helpers/foo/bar-baz.js', + exists: false + }, + { + file: 'tests/unit/helpers/foo/bar-baz-test.js', + exists: false + } + ] + }); + }); + + it('in-repo-addon helper foo-bar', function() { + return generateAndDestroy(['helper', 'foo-bar', '--in-repo-addon=my-addon'], { + target: 'inRepoAddon', + files: [ + { + file: 'lib/my-addon/addon/helpers/foo-bar.js', + contains: "import Ember from 'ember';\n\n" + + "export function fooBar(params/*, hash*/) {\n" + + " return params;\n" + + "}\n\n" + + "export default Ember.Helper.helper(fooBar);" + }, + { + file: 'lib/my-addon/app/helpers/foo-bar.js', + contains: [ + "export { default, fooBar } from 'my-addon/helpers/foo-bar';" + ] + }, + { + file: 'tests/unit/helpers/foo-bar-test.js', + contains: "import { fooBar } from 'my-app/helpers/foo-bar';" + } + ] + }); + }); + + it('in-repo-addon helper foo/bar-baz', function() { + return generateAndDestroy(['helper', 'foo/bar-baz', '--in-repo-addon=my-addon'], { + target: 'inRepoAddon', + files: [ + { + file: 'lib/my-addon/addon/helpers/foo/bar-baz.js', + contains: "import Ember from 'ember';\n\n" + + "export function fooBarBaz(params/*, hash*/) {\n" + + " return params;\n" + + "}\n\n" + + "export default Ember.Helper.helper(fooBarBaz);" + }, + { + file: 'lib/my-addon/app/helpers/foo/bar-baz.js', + contains: [ + "export { default, fooBarBaz } from 'my-addon/helpers/foo/bar-baz';" + ] + }, + { + file: 'tests/unit/helpers/foo/bar-baz-test.js', + contains: "import { fooBarBaz } from 'my-app/helpers/foo/bar-baz';" + } + ] + }); + }); + +/** +* Pod tests +* +*/ + it('helper foo-bar --pod', function() { + return generateAndDestroy(['helper', 'foo-bar', '--pod'], { + files: [ + { + file: 'app/helpers/foo-bar.js', + contains: "import Ember from 'ember';\n\n" + + "export function fooBar(params/*, hash*/) {\n" + + " return params;\n" + + "}\n\n" + + "export default Ember.Helper.helper(fooBar);" + }, + { + file: 'tests/unit/helpers/foo-bar-test.js', + contains: "import { fooBar } from 'my-app/helpers/foo-bar';" + } + ] + }); + }); + + it('helper foo-bar --pod podModulePrefix', function() { + return generateAndDestroy(['helper', 'foo-bar', '--pod'], { + podModulePrefix: true, + files: [ + { + file: 'app/helpers/foo-bar.js', + contains: "import Ember from 'ember';\n\n" + + "export function fooBar(params/*, hash*/) {\n" + + " return params;\n" + + "}\n\n" + + "export default Ember.Helper.helper(fooBar);" + }, + { + file: 'tests/unit/helpers/foo-bar-test.js', + contains: "import { fooBar } from 'my-app/helpers/foo-bar';" + } + ] + }); + }); + + it('helper foo/bar-baz --pod', function() { + return generateAndDestroy(['helper', 'foo/bar-baz', '--pod'], { + files: [ + { + file: 'app/helpers/foo/bar-baz.js', + contains: "import Ember from 'ember';\n\n" + + "export function fooBarBaz(params/*, hash*/) {\n" + + " return params;\n" + + "}\n\n" + + "export default Ember.Helper.helper(fooBarBaz);" + }, + { + file: 'tests/unit/helpers/foo/bar-baz-test.js', + contains: "import { fooBarBaz } from 'my-app/helpers/foo/bar-baz';" + } + ] + }); + }); + + it('helper foo/bar-baz --pod podModulePrefix', function() { + return generateAndDestroy(['helper', 'foo/bar-baz', '--pod'], { + podModulePrefix: true, + files: [ + { + file: 'app/helpers/foo/bar-baz.js', + contains: "import Ember from 'ember';\n\n" + + "export function fooBarBaz(params/*, hash*/) {\n" + + " return params;\n" + + "}\n\n" + + "export default Ember.Helper.helper(fooBarBaz);" + }, + { + file: 'tests/unit/helpers/foo/bar-baz-test.js', + contains: "import { fooBarBaz } from 'my-app/helpers/foo/bar-baz';" + } + ] + }); + }); + + it('helper-test foo/bar-baz', function() { + return generateAndDestroy(['helper-test', 'foo/bar-baz'], { + files: [ + { + file: 'tests/unit/helpers/foo/bar-baz-test.js', + contains: "import { fooBarBaz } from 'my-app/helpers/foo/bar-baz';" + } + ] + }); + }); + + it('in-addon helper-test foo-bar', function() { + return generateAndDestroy(['helper-test', 'foo-bar'], { + target: 'addon', + files: [ + { + file: 'tests/unit/helpers/foo-bar-test.js', + contains: "import { fooBar } from 'dummy/helpers/foo-bar';" + } + ] + }); + }); + + it('helper-test foo/bar-baz for mocha', function() { + return generateAndDestroy(['helper-test', 'foo/bar-baz'], { + packages: [ + { name: 'ember-cli-qunit', delete: true }, + { name: 'ember-cli-mocha', dev: true } + ], + files: [ + { + file: 'tests/unit/helpers/foo/bar-baz-test.js', + contains: [ + "import { describe, it } from 'mocha';", + "import { fooBarBaz } from 'my-app/helpers/foo/bar-baz';", + "describe('Unit | Helper | foo/bar baz', function() {" + ] + } + ] + }); + }); +}); diff --git a/node-tests/blueprints/initializer-addon-test.js b/node-tests/blueprints/initializer-addon-test.js new file mode 100644 index 0000000..b195b3c --- /dev/null +++ b/node-tests/blueprints/initializer-addon-test.js @@ -0,0 +1,24 @@ +'use strict'; + +var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup'); +var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper'); +var generateAndDestroy = BlueprintHelpers.generateAndDestroy; + +describe('Acceptance: ember generate and destroy initializer-addon', function() { + setupTestHooks(this); + + it('initializer-addon foo', function() { + // pass any additional command line options in the arguments array + return generateAndDestroy(['initializer-addon', 'foo'], { + // define files to assert, and their contents + target: 'addon', + files: [ + { + file: 'app/initializers/foo.js', + contains: "export { default, initialize } from 'my-addon/initializers/foo';" + } + ] + }); + }); + +}); diff --git a/node-tests/blueprints/initializer-test.js b/node-tests/blueprints/initializer-test.js new file mode 100644 index 0000000..978484a --- /dev/null +++ b/node-tests/blueprints/initializer-test.js @@ -0,0 +1,350 @@ +'use strict'; + +var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup'); +var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper'); +var generateAndDestroy = BlueprintHelpers.generateAndDestroy; + +describe('Acceptance: ember generate and destroy initializer', function() { + setupTestHooks(this); + + it('initializer foo', function() { + return generateAndDestroy(['initializer', 'foo'], { + files: [ + { + file:'app/initializers/foo.js', + contains: "export function initialize(/* application */) {\n" + + " // application.inject('route', 'foo', 'service:foo');\n" + + "}\n" + + "\n"+ + "export default {\n" + + " name: 'foo',\n" + + " initialize\n" + + "};" + }, + { + file:'tests/unit/initializers/foo-test.js', + contains: "import FooInitializer from 'my-app/initializers/foo';" + } + ] + }); + }); + + it('initializer foo/bar', function() { + return generateAndDestroy(['initializer', 'foo/bar'], { + files: [ + { + file:'app/initializers/foo/bar.js', + contains: "export function initialize(/* application */) {\n" + + " // application.inject('route', 'foo', 'service:foo');\n" + + "}\n" + + "\n"+ + "export default {\n" + + " name: 'foo/bar',\n" + + " initialize\n" + + "};" + }, + { + file:'tests/unit/initializers/foo/bar-test.js', + contains: "import FooBarInitializer from 'my-app/initializers/foo/bar';" + } + ] + }); + }); + + it('in-addon initializer foo', function() { + return generateAndDestroy(['initializer', 'foo'], { + target: 'addon', + files: [ + { + file: 'addon/initializers/foo.js', + contains: "export function initialize(/* application */) {\n" + + " // application.inject('route', 'foo', 'service:foo');\n" + + "}\n" + + "\n"+ + "export default {\n" + + " name: 'foo',\n" + + " initialize\n" + + "};" + }, + { + file: 'app/initializers/foo.js', + contains: [ + "export { default, initialize } from 'my-addon/initializers/foo';" + ] + }, + { + file: 'tests/unit/initializers/foo-test.js' + } + ] + }); + }); + + it('in-addon initializer foo/bar', function() { + return generateAndDestroy(['initializer', 'foo/bar'], { + target: 'addon', + files: [ + { + file: 'addon/initializers/foo/bar.js', + contains: "export function initialize(/* application */) {\n" + + " // application.inject('route', 'foo', 'service:foo');\n" + + "}\n" + + "\n"+ + "export default {\n" + + " name: 'foo/bar',\n" + + " initialize\n" + + "};" + }, + { + file: 'app/initializers/foo/bar.js', + contains: [ + "export { default, initialize } from 'my-addon/initializers/foo/bar';" + ] + }, + { + file: 'tests/unit/initializers/foo/bar-test.js' + } + ] + }); + }); + + it('dummy initializer foo', function() { + return generateAndDestroy(['initializer', 'foo', '--dummy'], { + target: 'addon', + files: [ + { + file: 'tests/dummy/app/initializers/foo.js', + contains: "export function initialize(/* application */) {\n" + + " // application.inject('route', 'foo', 'service:foo');\n" + + "}\n" + + "\n"+ + "export default {\n" + + " name: 'foo',\n" + + " initialize\n" + + "};" + }, + { + file: 'app/initializers/foo.js', + exists: false + }, + { + file: 'tests/unit/initializers/foo-test.js', + exists: false + } + ] + }); + }); + + it('dummy initializer foo/bar', function() { + return generateAndDestroy(['initializer', 'foo/bar', '--dummy'], { + target: 'addon', + files: [ + { + file: 'tests/dummy/app/initializers/foo/bar.js', + contains: "export function initialize(/* application */) {\n" + + " // application.inject('route', 'foo', 'service:foo');\n" + + "}\n" + + "\n"+ + "export default {\n" + + " name: 'foo/bar',\n" + + " initialize\n" + + "};" + }, + { + file: 'app/initializers/foo/bar.js', + exists: false + }, + { + file: 'tests/unit/initializers/foo/bar-test.js', + exists: false + } + ] + }); + }); + + it('in-repo-addon initializer foo', function() { + return generateAndDestroy(['initializer', 'foo', '--in-repo-addon=my-addon'], { + target: 'inRepoAddon', + files: [ + { + file: 'lib/my-addon/addon/initializers/foo.js', + contains: "export function initialize(/* application */) {\n" + + " // application.inject('route', 'foo', 'service:foo');\n" + + "}\n" + + "\n"+ + "export default {\n" + + " name: 'foo',\n" + + " initialize\n" + + "};" + }, + { + file: 'lib/my-addon/app/initializers/foo.js', + contains: [ + "export { default, initialize } from 'my-addon/initializers/foo';" + ] + }, + { + file: 'tests/unit/initializers/foo-test.js' + } + ] + }); + }); + + it('in-repo-addon initializer foo/bar', function() { + return generateAndDestroy(['initializer', 'foo/bar', '--in-repo-addon=my-addon'], { + target: 'inRepoAddon', + files: [ + { + file: 'lib/my-addon/addon/initializers/foo/bar.js', + contains: "export function initialize(/* application */) {\n" + + " // application.inject('route', 'foo', 'service:foo');\n" + + "}\n" + + "\n"+ + "export default {\n" + + " name: 'foo/bar',\n" + + " initialize\n" + + "};" + }, + { + file: 'lib/my-addon/app/initializers/foo/bar.js', + contains: [ + "export { default, initialize } from 'my-addon/initializers/foo/bar';" + ] + }, + { + file: 'tests/unit/initializers/foo/bar-test.js' + } + ] + }); + }); + + /* Pod tests */ + + it('initializer foo --pod', function() { + return generateAndDestroy(['initializer', 'foo', '--pod'], { + files: [ + { + file: 'app/initializers/foo.js', + contains: "export function initialize(/* application */) {\n" + + " // application.inject('route', 'foo', 'service:foo');\n" + + "}\n" + + "\n"+ + "export default {\n" + + " name: 'foo',\n" + + " initialize\n" + + "};" + } + ] + }); + }); + + it('initializer foo --pod podModulePrefix', function() { + return generateAndDestroy(['initializer', 'foo', '--pod'], { + podModulePrefix: true, + files: [ + { + file: 'app/initializers/foo.js', + contains: "export function initialize(/* application */) {\n" + + " // application.inject('route', 'foo', 'service:foo');\n" + + "}\n" + + "\n"+ + "export default {\n" + + " name: 'foo',\n" + + " initialize\n" + + "};" + } + ] + }); + }); + + it('initializer foo/bar --pod', function() { + return generateAndDestroy(['initializer', 'foo/bar', '--pod'], { + files: [ + { + file: 'app/initializers/foo/bar.js', + contains: "export function initialize(/* application */) {\n" + + " // application.inject('route', 'foo', 'service:foo');\n" + + "}\n" + + "\n"+ + "export default {\n" + + " name: 'foo/bar',\n" + + " initialize\n" + + "};" + } + ] + }); + }); + + + it('initializer foo/bar --pod podModulePrefix', function() { + return generateAndDestroy(['initializer', 'foo/bar', '--pod'], { + podModulePrefix: true, + files: [ + { + file: 'app/initializers/foo/bar.js', + contains: "export function initialize(/* application */) {\n" + + " // application.inject('route', 'foo', 'service:foo');\n" + + "}\n" + + "\n"+ + "export default {\n" + + " name: 'foo/bar',\n" + + " initialize\n" + + "};" + } + ] + }); + }); + + + it('initializer-test foo', function() { + return generateAndDestroy(['initializer-test', 'foo'], { + files: [ + { + file: 'tests/unit/initializers/foo-test.js', + contains: [ + "import FooInitializer from 'my-app/initializers/foo';", + "module('Unit | Initializer | foo'", + "application = Ember.Application.create();", + "FooInitializer.initialize(application);" + ] + } + ] + }); + }); + + it('in-addon initializer-test foo', function() { + return generateAndDestroy(['initializer-test', 'foo'], { + target: 'addon', + files: [ + { + file: 'tests/unit/initializers/foo-test.js', + contains: [ + "import FooInitializer from 'dummy/initializers/foo';", + "module('Unit | Initializer | foo'", + "application = Ember.Application.create();", + "FooInitializer.initialize(application);" + ] + } + ] + }); + }); + + it('initializer-test foo for mocha', function() { + return generateAndDestroy(['initializer-test', 'foo'], { + packages: [ + { name: 'ember-cli-qunit', delete: true }, + { name: 'ember-cli-mocha', dev: true } + ], + files: [ + { + file: 'tests/unit/initializers/foo-test.js', + contains: [ + "import FooInitializer from 'my-app/initializers/foo';", + "describe('Unit | Initializer | foo', function() {", + "application = Ember.Application.create();", + "FooInitializer.initialize(application);" + ] + } + ] + }); + }); +}); diff --git a/node-tests/blueprints/instance-initializer-addon-test.js b/node-tests/blueprints/instance-initializer-addon-test.js new file mode 100644 index 0000000..6e159cb --- /dev/null +++ b/node-tests/blueprints/instance-initializer-addon-test.js @@ -0,0 +1,25 @@ +'use strict'; + +var tmpenv = require('ember-cli-blueprint-test-helpers/lib/helpers/tmp-env'); +var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup'); +var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper'); +var generateAndDestroy = BlueprintHelpers.generateAndDestroy; + +describe('Acceptance: ember generate and destroy instance-initializer-addon', function() { + setupTestHooks(this, tmpenv); + + it('instance-initializer-addon foo', function() { + // pass any additional command line options in the arguments array + return generateAndDestroy(['instance-initializer-addon', 'foo'], { + // define files to assert, and their contents + target: 'addon', + files: [ + { + file: 'app/instance-initializers/foo.js', + contains: "export { default, initialize } from 'my-addon/instance-initializers/foo';" + } + ] + }); + }); + +}); diff --git a/node-tests/blueprints/instance-initializer-test.js b/node-tests/blueprints/instance-initializer-test.js new file mode 100644 index 0000000..94e7e0b --- /dev/null +++ b/node-tests/blueprints/instance-initializer-test.js @@ -0,0 +1,353 @@ +'use strict'; + +var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup'); +var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper'); +var generateAndDestroy = BlueprintHelpers.generateAndDestroy; + +describe('Acceptance: ember generate and destroy instance-initializer', function() { + setupTestHooks(this); + + it('instance-initializer foo', function() { + return generateAndDestroy(['instance-initializer', 'foo'], { + files: [ + { + file:'app/instance-initializers/foo.js', + contains: "export function initialize(/* appInstance */) {\n" + + " // appInstance.inject('route', 'foo', 'service:foo');\n" + + "}\n" + + "\n"+ + "export default {\n" + + " name: 'foo',\n" + + " initialize\n" + + "};" + }, + { + file:'tests/unit/instance-initializers/foo-test.js', + contains: "import { initialize } from 'my-app/instance-initializers/foo';" + } + ] + }); + }); + + it('instance-initializer foo/bar', function() { + return generateAndDestroy(['instance-initializer', 'foo/bar'], { + files: [ + { + file:'app/instance-initializers/foo/bar.js', + contains: "export function initialize(/* appInstance */) {\n" + + " // appInstance.inject('route', 'foo', 'service:foo');\n" + + "}\n" + + "\n"+ + "export default {\n" + + " name: 'foo/bar',\n" + + " initialize\n" + + "};" + }, + { + file:'tests/unit/instance-initializers/foo/bar-test.js', + contains: "import { initialize } from 'my-app/instance-initializers/foo/bar';" + } + ] + }); + }); + + it('in-addon instance-initializer foo', function() { + return generateAndDestroy(['instance-initializer', 'foo'], { + target: 'addon', + files: [ + { + file: 'addon/instance-initializers/foo.js', + contains: "export function initialize(/* appInstance */) {\n" + + " // appInstance.inject('route', 'foo', 'service:foo');\n" + + "}\n" + + "\n"+ + "export default {\n" + + " name: 'foo',\n" + + " initialize\n" + + "};" + }, + { + file: 'app/instance-initializers/foo.js', + contains: [ + "export { default, initialize } from 'my-addon/instance-initializers/foo';" + ] + }, + { + file: 'tests/unit/instance-initializers/foo-test.js' + } + ] + }); + }); + + it('in-addon instance-initializer foo/bar', function() { + return generateAndDestroy(['instance-initializer', 'foo/bar'], { + target: 'addon', + files: [ + { + file: 'addon/instance-initializers/foo/bar.js', + contains: "export function initialize(/* appInstance */) {\n" + + " // appInstance.inject('route', 'foo', 'service:foo');\n" + + "}\n" + + "\n"+ + "export default {\n" + + " name: 'foo/bar',\n" + + " initialize\n" + + "};" + }, + { + file: 'app/instance-initializers/foo/bar.js', + contains: [ + "export { default, initialize } from 'my-addon/instance-initializers/foo/bar';" + ] + }, + { + file: 'tests/unit/instance-initializers/foo/bar-test.js' + } + ] + }); + }); + + it('dummy instance-initializer foo', function() { + return generateAndDestroy(['instance-initializer', 'foo', '--dummy'], { + target: 'addon', + files: [ + { + file: 'tests/dummy/app/instance-initializers/foo.js', + contains: "export function initialize(/* appInstance */) {\n" + + " // appInstance.inject('route', 'foo', 'service:foo');\n" + + "}\n" + + "\n"+ + "export default {\n" + + " name: 'foo',\n" + + " initialize\n" + + "};" + }, + { + file: 'app/instance-initializers/foo.js', + exists: false + }, + { + file: 'tests/unit/instance-initializers/foo-test.js', + exists: false + } + ] + }); + }); + + it('dummy instance-initializer foo/bar', function() { + return generateAndDestroy(['instance-initializer', 'foo/bar', '--dummy'], { + target: 'addon', + files: [ + { + file: 'tests/dummy/app/instance-initializers/foo/bar.js', + contains: "export function initialize(/* appInstance */) {\n" + + " // appInstance.inject('route', 'foo', 'service:foo');\n" + + "}\n" + + "\n"+ + "export default {\n" + + " name: 'foo/bar',\n" + + " initialize\n" + + "};" + }, + { + file: 'app/instance-initializers/foo/bar.js', + exists: false + }, + { + file: 'tests/unit/instance-initializers/foo/bar-test.js', + exists: false + } + ] + }); + }); + + it('in-repo-addon instance-initializer foo', function() { + return generateAndDestroy(['instance-initializer', 'foo', '--in-repo-addon=my-addon'], { + target: 'inRepoAddon', + files: [ + { + file: 'lib/my-addon/addon/instance-initializers/foo.js', + contains: "export function initialize(/* appInstance */) {\n" + + " // appInstance.inject('route', 'foo', 'service:foo');\n" + + "}\n" + + "\n"+ + "export default {\n" + + " name: 'foo',\n" + + " initialize\n" + + "};" + }, + { + file: 'lib/my-addon/app/instance-initializers/foo.js', + contains: [ + "export { default, initialize } from 'my-addon/instance-initializers/foo';" + ] + }, + { + file: 'tests/unit/instance-initializers/foo-test.js' + } + ] + }); + }); + + it('in-repo-addon instance-initializer foo/bar', function() { + return generateAndDestroy(['instance-initializer', 'foo/bar', '--in-repo-addon=my-addon'], { + target: 'inRepoAddon', + files: [ + { + file: 'lib/my-addon/addon/instance-initializers/foo/bar.js', + contains: "export function initialize(/* appInstance */) {\n" + + " // appInstance.inject('route', 'foo', 'service:foo');\n" + + "}\n" + + "\n"+ + "export default {\n" + + " name: 'foo/bar',\n" + + " initialize\n" + + "};" + }, + { + file: 'lib/my-addon/app/instance-initializers/foo/bar.js', + contains: [ + "export { default, initialize } from 'my-addon/instance-initializers/foo/bar';" + ] + }, + { + file: 'tests/unit/instance-initializers/foo/bar-test.js' + } + ] + }); + }); + + /* Pod tests */ + + it('instance-initializer foo --pod', function() { + return generateAndDestroy(['instance-initializer', 'foo', '--pod'], { + files: [ + { + file: 'app/instance-initializers/foo.js', + contains: "export function initialize(/* appInstance */) {\n" + + " // appInstance.inject('route', 'foo', 'service:foo');\n" + + "}\n" + + "\n"+ + "export default {\n" + + " name: 'foo',\n" + + " initialize\n" + + "};" + } + ] + }); + }); + + it('instance-initializer foo --pod podModulePrefix', function() { + return generateAndDestroy(['instance-initializer', 'foo', '--pod'], { + podModulePrefix: true, + files: [ + { + file: 'app/instance-initializers/foo.js', + contains: "export function initialize(/* appInstance */) {\n" + + " // appInstance.inject('route', 'foo', 'service:foo');\n" + + "}\n" + + "\n"+ + "export default {\n" + + " name: 'foo',\n" + + " initialize\n" + + "};" + } + ] + }); + }); + + it('instance-initializer foo/bar --pod', function() { + return generateAndDestroy(['instance-initializer', 'foo/bar', '--pod'], { + files: [ + { + file: 'app/instance-initializers/foo/bar.js', + contains: "export function initialize(/* appInstance */) {\n" + + " // appInstance.inject('route', 'foo', 'service:foo');\n" + + "}\n" + + "\n"+ + "export default {\n" + + " name: 'foo/bar',\n" + + " initialize\n" + + "};" + } + ] + }); + }); + + + it('instance-initializer foo/bar --pod podModulePrefix', function() { + return generateAndDestroy(['instance-initializer', 'foo/bar', '--pod'], { + podModulePrefix: true, + files: [ + { + file: 'app/instance-initializers/foo/bar.js', + contains: "export function initialize(/* appInstance */) {\n" + + " // appInstance.inject('route', 'foo', 'service:foo');\n" + + "}\n" + + "\n"+ + "export default {\n" + + " name: 'foo/bar',\n" + + " initialize\n" + + "};" + } + ] + }); + }); + + + it('instance-initializer-test foo', function() { + return generateAndDestroy(['instance-initializer-test', 'foo'], { + files: [ + { + file: 'tests/unit/instance-initializers/foo-test.js', + contains: [ + "import { initialize } from 'my-app/instance-initializers/foo';", + "module('Unit | Instance Initializer | foo'", + "application = Ember.Application.create();", + "this.appInstance = this.application.buildInstance();", + "initialize(this.appInstance);" + ] + } + ] + }); + }); + + it('in-addon instance-initializer-test foo', function() { + return generateAndDestroy(['instance-initializer-test', 'foo'], { + target: 'addon', + files: [ + { + file: 'tests/unit/instance-initializers/foo-test.js', + contains: [ + "import { initialize } from 'dummy/instance-initializers/foo';", + "module('Unit | Instance Initializer | foo'", + "application = Ember.Application.create();", + "this.appInstance = this.application.buildInstance();", + "initialize(this.appInstance);" + ] + } + ] + }); + }); + + it('instance-initializer-test foo for mocha', function() { + return generateAndDestroy(['instance-initializer-test', 'foo'], { + packages: [ + { name: 'ember-cli-qunit', delete: true }, + { name: 'ember-cli-mocha', dev: true } + ], + files: [ + { + file: 'tests/unit/instance-initializers/foo-test.js', + contains: [ + "import { initialize } from 'my-app/instance-initializers/foo';", + "describe('Unit | Instance Initializer | foo', function() {", + "application = Ember.Application.create();", + "appInstance = application.buildInstance();", + "initialize(appInstance);" + ] + } + ] + }); + }); +}); diff --git a/node-tests/blueprints/mixin-test.js b/node-tests/blueprints/mixin-test.js new file mode 100644 index 0000000..37eb296 --- /dev/null +++ b/node-tests/blueprints/mixin-test.js @@ -0,0 +1,336 @@ +'use strict'; + +var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup'); +var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper'); +var generateAndDestroy = BlueprintHelpers.generateAndDestroy; + +describe('Acceptance: ember generate and destroy mixin', function() { + setupTestHooks(this); + + it('mixin foo', function() { + return generateAndDestroy(['mixin', 'foo'], { + files: [ + { + file: 'app/mixins/foo.js', + contains: [ + "import Ember from 'ember';", + 'export default Ember.Mixin.create({\n});' + ] + }, + { + file: 'tests/unit/mixins/foo-test.js', + contains: [ + "import FooMixin from 'my-app/mixins/foo';" + ] + } + ] + }); + }); + + it('mixin foo/bar', function() { + return generateAndDestroy(['mixin', 'foo/bar'], { + files: [ + { + file: 'app/mixins/foo/bar.js', + contains: [ + "import Ember from 'ember';", + 'export default Ember.Mixin.create({\n});' + ] + }, + { + file: 'tests/unit/mixins/foo/bar-test.js', + contains: [ + "import FooBarMixin from 'my-app/mixins/foo/bar';" + ] + } + ] + }); + }); + + it('mixin foo/bar/baz', function() { + return generateAndDestroy(['mixin', 'foo/bar/baz'], { + files: [ + { + file: 'tests/unit/mixins/foo/bar/baz-test.js', + contains: [ + "import FooBarBazMixin from 'my-app/mixins/foo/bar/baz';" + ] + } + ] + }); + }); + + it('in-addon mixin foo', function() { + return generateAndDestroy(['mixin', 'foo'], { + target: 'addon', + files: [ + { + file: 'addon/mixins/foo.js', + contains: [ + "import Ember from 'ember';", + 'export default Ember.Mixin.create({\n});' + ] + }, + { + file: 'tests/unit/mixins/foo-test.js', + contains: [ + "import FooMixin from 'my-addon/mixins/foo';" + ] + }, + { + file: 'app/mixins/foo.js', + exists: false + } + ] + }); + }); + + it('in-addon mixin foo/bar', function() { + return generateAndDestroy(['mixin', 'foo/bar'], { + target: 'addon', + files: [ + { + file: 'addon/mixins/foo/bar.js', + contains: [ + "import Ember from 'ember';", + 'export default Ember.Mixin.create({\n});' + ] + }, + { + file: 'tests/unit/mixins/foo/bar-test.js', + contains: [ + "import FooBarMixin from 'my-addon/mixins/foo/bar';" + ] + }, + { + file: 'app/mixins/foo/bar.js', + exists: false + } + ] + }); + }); + + it('in-addon mixin foo/bar/baz', function() { + return generateAndDestroy(['mixin', 'foo/bar/baz'], { + target: 'addon', + files: [ + { + file: 'addon/mixins/foo/bar/baz.js', + contains: [ + "import Ember from 'ember';", + 'export default Ember.Mixin.create({\n});' + ] + }, + { + file: 'tests/unit/mixins/foo/bar/baz-test.js', + contains: [ + "import FooBarBazMixin from 'my-addon/mixins/foo/bar/baz';" + ] + }, + { + file: 'app/mixins/foo/bar/baz.js', + exists: false + } + ] + }); + }) + + it('in-repo-addon mixin foo', function() { + return generateAndDestroy(['mixin', 'foo', '--in-repo-addon=my-addon'], { + target: 'inRepoAddon', + files: [ + { + file: 'lib/my-addon/addon/mixins/foo.js', + contains: [ + "import Ember from 'ember';", + 'export default Ember.Mixin.create({\n});' + ] + }, + { + file: 'tests/unit/mixins/foo-test.js', + contains: [ + "import FooMixin from 'my-addon/mixins/foo';" + ] + } + ] + }); + }); + + it('in-repo-addon mixin foo/bar', function() { + return generateAndDestroy(['mixin', 'foo/bar', '--in-repo-addon=my-addon'], { + target: 'inRepoAddon', + files: [ + { + file: 'lib/my-addon/addon/mixins/foo/bar.js', + contains: [ + "import Ember from 'ember';", + 'export default Ember.Mixin.create({\n});' + ] + }, + { + file: 'tests/unit/mixins/foo/bar-test.js', + contains: [ + "import FooBarMixin from 'my-addon/mixins/foo/bar';" + ] + } + ] + }); + }); + + it('in-repo-addon mixin foo/bar/baz', function() { + return generateAndDestroy(['mixin', 'foo/bar/baz', '--in-repo-addon=my-addon'], { + target: 'inRepoAddon', + files: [ + { + file: 'tests/unit/mixins/foo/bar/baz-test.js', + contains: [ + "import FooBarBazMixin from 'my-addon/mixins/foo/bar/baz';" + ] + } + ] + }); + }); + + /* Pod tests */ + + it('mixin foo --pod', function() { + return generateAndDestroy(['mixin', 'foo', '--pod'], { + files: [ + { + file: 'app/mixins/foo.js', + contains: [ + "import Ember from 'ember';", + 'export default Ember.Mixin.create({\n});' + ] + }, + { + file: 'tests/unit/mixins/foo-test.js', + contains: [ + "import FooMixin from 'my-app/mixins/foo';" + ] + } + ] + }); + }); + + it('mixin foo --pod podModulePrefix', function() { + return generateAndDestroy(['mixin', 'foo', '--pod'], { + podModulePrefix: true, + files: [ + { + file: 'app/mixins/foo.js', + contains: [ + "import Ember from 'ember';", + 'export default Ember.Mixin.create({\n});' + ] + }, + { + file: 'tests/unit/mixins/foo-test.js', + contains: [ + "import FooMixin from 'my-app/mixins/foo';" + ] + } + ] + }); + }); + + it('mixin foo/bar --pod', function() { + return generateAndDestroy(['mixin', 'foo/bar', '--pod'], { + files: [ + { + file: 'app/mixins/foo/bar.js', + contains: [ + "import Ember from 'ember';", + 'export default Ember.Mixin.create({\n});' + ] + }, + { + file: 'tests/unit/mixins/foo/bar-test.js', + contains: [ + "import FooBarMixin from 'my-app/mixins/foo/bar';" + ] + } + ] + }); + }); + + it('mixin foo/bar --pod podModulePrefix', function() { + return generateAndDestroy(['mixin', 'foo/bar', '--pod'], { + podModulePrefix: true, + files: [ + { + file: 'app/mixins/foo/bar.js', + contains: [ + "import Ember from 'ember';", + 'export default Ember.Mixin.create({\n});' + ] + }, + { + file: 'tests/unit/mixins/foo/bar-test.js', + contains: [ + "import FooBarMixin from 'my-app/mixins/foo/bar';" + ] + } + ] + }); + }); + + it('mixin foo/bar/baz --pod', function() { + return generateAndDestroy(['mixin', 'foo/bar/baz', '--pod'], { + files: [ + { + file: 'tests/unit/mixins/foo/bar/baz-test.js', + contains: [ + "import FooBarBazMixin from 'my-app/mixins/foo/bar/baz';" + ] + } + ] + }); + }); + + it('mixin-test foo', function() { + return generateAndDestroy(['mixin-test', 'foo'], { + files: [ + { + file: 'tests/unit/mixins/foo-test.js', + contains: [ + "import FooMixin from 'my-app/mixins/foo';" + ] + } + ] + }); + }); + + it('in-addon mixin-test foo', function() { + return generateAndDestroy(['mixin-test', 'foo'], { + target: 'addon', + files: [ + { + file: 'tests/unit/mixins/foo-test.js', + contains: [ + "import FooMixin from 'my-addon/mixins/foo';" + ] + } + ] + }); + }); + + it('mixin-test foo for mocha', function() { + return generateAndDestroy(['mixin-test', 'foo'], { + packages: [ + { name: 'ember-cli-qunit', delete: true }, + { name: 'ember-cli-mocha', dev: true } + ], + files: [ + { + file: 'tests/unit/mixins/foo-test.js', + contains: [ + "import { describe, it } from 'mocha';", + "import FooMixin from 'my-app/mixins/foo';", + "describe('Unit | Mixin | foo', function() {" + ] + } + ] + }); + }); +}); diff --git a/node-tests/blueprints/route-addon-test.js b/node-tests/blueprints/route-addon-test.js new file mode 100644 index 0000000..ae1307d --- /dev/null +++ b/node-tests/blueprints/route-addon-test.js @@ -0,0 +1,30 @@ +'use strict'; + +var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup'); +var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper'); +var generateAndDestroy = BlueprintHelpers.generateAndDestroy; + +describe('Acceptance: ember generate and destroy route-addon', function() { + setupTestHooks(this); + + it('route-addon foo', function() { + return generateAndDestroy(['route-addon', 'foo'], { + target: 'addon', + files: [ + { + file: 'app/routes/foo.js', + contains: [ + "export { default } from 'my-addon/routes/foo';" + ] + }, + { + file: 'app/templates/foo.js', + contains: [ + "export { default } from 'my-addon/templates/foo';" + ] + }, + ] + }); + }); + +}); diff --git a/node-tests/blueprints/route-test.js b/node-tests/blueprints/route-test.js new file mode 100644 index 0000000..918eb4b --- /dev/null +++ b/node-tests/blueprints/route-test.js @@ -0,0 +1,674 @@ +'use strict'; + +var fs = require('fs-extra'); +var path = require('path'); +var RSVP = require('rsvp'); +var remove = RSVP.denodeify(fs.remove); +var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup'); +var initProject = require('ember-cli-blueprint-test-helpers/lib/helpers/project-init'); +var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper'); +var generateAndDestroy = BlueprintHelpers.generateAndDestroy; +var destroy = BlueprintHelpers.destroy; + + +describe('Acceptance: ember generate and destroy route', function() { + setupTestHooks(this); + + it('route foo', function() { + var files = [ + { + file: 'app/router.js', + contains: 'this.route(\'foo\')' + }, + { + file: 'app/routes/foo.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Route.extend({\n});" + ] + }, + { + file: 'app/templates/foo.hbs', + contains: '{{outlet}}' + }, + { + file: 'tests/unit/routes/foo-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('route:foo'" + ] + } + ]; + + return generateAndDestroy(['route', 'foo'], { + afterDestroy: function() { + // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38 + files.shift(); + }, + files: files, + }); + }); + + it('route foo with --skip-router', function() { + var files = [ + { + file: 'app/router.js', + doesNotContain: 'this.route(\'foo\')' + }, + { + file: 'app/routes/foo.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Route.extend({\n});" + ] + }, + { + file: 'app/templates/foo.hbs', + contains: '{{outlet}}' + }, + { + file: 'tests/unit/routes/foo-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('route:foo'" + ] + } + ]; + + return generateAndDestroy(['route', 'foo', '--skip-router'], { + afterDestroy: function() { + // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38 + files.shift(); + }, + files: files, + }); + }); + + it('route foo with --path', function() { + var files = [ + { + file: 'app/router.js', + contains: [ + 'this.route(\'foo\', {', + 'path: \':foo_id/show\'', + '});' + ] + } + ]; + + return generateAndDestroy(['route', 'foo', '--path=:foo_id/show'], { + afterDestroy: function() { + // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38 + files.shift(); + }, + files: files, + }); + }); + + it('route index', function() { + var files = [ + { + file: 'app/router.js', + doesNotContain: "this.route('index');" + } + ]; + + return generateAndDestroy(['route', 'index'], { + afterDestroy: function() { + // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38 + files.shift(); + }, + files: files, + }); + }); + + it('route application', function() { + return generateAndDestroy(['route', 'foo'], { + afterGenerate: function(){ + return remove(path.join('app', 'templates', 'application.hbs')) + .then(function() { + var files = [ + { + file: 'app/router.js', + doesNotContain: "this.route('application');" + } + ]; + + return generateAndDestroy(['route', 'application'], { + skipInit: true, + afterDestroy: function() { + // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38 + files.shift(); + }, + files: files, + }); + }); + } + }); + }); + + it('route basic isn\'t added to router', function() { + var files = [ + { + file: 'app/router.js', + doesNotContain: "this.route('basic');" + }, + { + file: 'app/routes/basic.js' + } + ]; + + return generateAndDestroy(['route', 'basic'], { + afterDestroy: function() { + // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38 + files.shift(); + }, + files: files, + }); + }); + + it('in-addon route foo', function() { + var files = [ + { + file: 'addon/routes/foo.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Route.extend({\n});" + ] + }, + { + file: 'app/routes/foo.js', + contains: [ + "export { default } from 'my-addon/routes/foo';" + ] + }, + { + file: 'addon/templates/foo.hbs', + contains: '{{outlet}}' + }, + { + file: 'app/templates/foo.js', + contains: "export { default } from 'my-addon/templates/foo';" + }, + { + file: 'tests/unit/routes/foo-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('route:foo'" + ] + }, + { + file: 'tests/dummy/app/router.js', + doesNotContain: "this.route('foo');" + } + ]; + + return generateAndDestroy(['route', 'foo'], { + target: 'addon', + afterDestroy: function() { + // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38 + files.pop(); + }, + files: files, + }); + }); + + it('in-addon route foo/bar', function() { + var files = [ + { + file: 'addon/routes/foo/bar.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Route.extend({\n});" + ] + }, + { + file: 'app/routes/foo/bar.js', + contains: "export { default } from 'my-addon/routes/foo/bar';" + }, + { + file: 'app/templates/foo/bar.js', + contains: "export { default } from 'my-addon/templates/foo/bar';" + }, + { + file: 'tests/unit/routes/foo/bar-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('route:foo/bar'" + ] + }, + { + file: 'tests/dummy/app/router.js', + doesNotContain: "this.route('bar');" + } + ]; + + return generateAndDestroy(['route', 'foo/bar'], { + target: 'addon', + afterDestroy: function() { + // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38 + files.pop(); + }, + files: files, + }); + }); + + it('dummy route foo', function() { + var files = [ + { + file: 'tests/dummy/app/router.js', + contains: "this.route('foo');" + }, + { + file: 'tests/dummy/app/routes/foo.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Route.extend({\n});" + ] + }, + { + file: 'app/routes/foo.js', + exists: false + }, + { + file: 'tests/dummy/app/templates/foo.hbs', + contains: '{{outlet}}' + }, + { + file: 'app/templates/foo.js', + exists: false + }, + { + file: 'tests/unit/routes/foo-test.js', + exists: false + } + ]; + + return generateAndDestroy(['route', 'foo', '--dummy'], { + target: 'addon', + afterDestroy: function() { + // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38 + files.shift(); + }, + files: files, + }); + }); + + it('dummy route foo/bar', function() { + var files = [ + { + file: 'tests/dummy/app/router.js', + contains: [ + "this.route('foo', function() {", + "this.route('bar');", + ] + }, + { + file: 'tests/dummy/app/routes/foo/bar.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Route.extend({\n});" + ] + }, + { + file: 'app/routes/foo/bar.js', + exists: false + }, + { + file: 'tests/dummy/app/templates/foo/bar.hbs', + contains: '{{outlet}}' + }, + { + file: 'tests/unit/routes/foo/bar-test.js', + exists: false + } + ]; + + return generateAndDestroy(['route', 'foo/bar', '--dummy'], { + target: 'addon', + afterDestroy: function() { + // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38 + files.shift(); + }, + files: files, + }); + }); + + it('in-repo-addon route foo', function() { + return generateAndDestroy(['route', 'foo', '--in-repo-addon=my-addon'], { + target: 'inRepoAddon', + files: [ + { + file: 'lib/my-addon/addon/routes/foo.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Route.extend({\n});" + ] + }, + { + file: 'lib/my-addon/app/routes/foo.js', + contains: "export { default } from 'my-addon/routes/foo';" + }, + { + file: 'lib/my-addon/addon/templates/foo.hbs', + contains: '{{outlet}}' + }, + { + file: 'lib/my-addon/app/templates/foo.js', + contains: "export { default } from 'my-addon/templates/foo';" + }, + { + file: 'tests/unit/routes/foo-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('route:foo'" + ] + } + ] + }); + }); + + it('in-repo-addon route foo/bar', function() { + return generateAndDestroy(['route', 'foo/bar', '--in-repo-addon=my-addon'], { + target: 'inRepoAddon', + files: [ + { + file: 'lib/my-addon/addon/routes/foo/bar.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Route.extend({\n});" + ] + }, + { + file: 'lib/my-addon/app/routes/foo/bar.js', + contains: "export { default } from 'my-addon/routes/foo/bar';" + }, + { + file: 'lib/my-addon/addon/templates/foo/bar.hbs', + contains: '{{outlet}}' + }, + { + file: 'lib/my-addon/app/templates/foo/bar.js', + contains: "export { default } from 'my-addon/templates/foo/bar';" + }, + { + file: 'tests/unit/routes/foo/bar-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('route:foo/bar'" + ] + } + ] + }); + }); + +/** +* Pod tests +* +*/ + + it('in-addon route foo --pod', function() { + return generateAndDestroy(['route', 'foo', '--pod'], { + target: 'addon', + files: [ + { + file: 'addon/foo/route.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Route.extend({\n});" + ] + }, + { + file: 'addon/foo/template.hbs', + contains: "{{outlet}}" + }, + { + file: 'app/foo/route.js', + contains: [ + "export { default } from 'my-addon/foo/route';" + ] + }, + { + file: 'app/foo/template.js', + contains: [ + "export { default } from 'my-addon/foo/template';" + ] + }, + { + file: 'tests/unit/foo/route-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('route:foo'" + ] + } + ] + }); + }); + + + it('route foo --pod', function() { + var files = [ + { + file: 'app/router.js', + contains: 'this.route(\'foo\')' + }, + { + file: 'app/foo/route.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Route.extend({\n});" + ] + }, + { + file: 'app/foo/template.hbs', + contains: '{{outlet}}' + }, + { + file: 'tests/unit/foo/route-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('route:foo'" + ] + } + ]; + + return generateAndDestroy(['route', 'foo', '--pod'], { + afterDestroy: function() { + // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38 + files.shift(); + }, + files: files, + }); + }); + + it('route foo --pod with --path', function() { + var files = [ + { + file: 'app/router.js', + contains: [ + 'this.route(\'foo\', {', + 'path: \':foo_id/show\'', + '});' + ] + } + ]; + + return generateAndDestroy(['route', 'foo', '--pod', '--path=:foo_id/show'], { + afterDestroy: function() { + // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38 + files.shift(); + }, + files: files, + }); + }); + + + it('route foo --pod podModulePrefix', function() { + var files = [ + { + file: 'app/router.js', + contains: 'this.route(\'foo\')' + }, + { + file: 'app/pods/foo/route.js', + contains: [ + "import Ember from 'ember';", + "export default Ember.Route.extend({\n});" + ] + }, + { + file: 'app/pods/foo/template.hbs', + contains: '{{outlet}}' + }, + { + file: 'tests/unit/pods/foo/route-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('route:foo'" + ] + } + ]; + + return generateAndDestroy(['route', 'foo', '--pod'], { + podModulePrefix: true, + afterDestroy: function() { + // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38 + files.shift(); + }, + files: files, + }); + }); + + it('route index --pod', function() { + var files = [ + { + file: 'app/router.js', + doesNotContain: "this.route('index');" + } + ]; + + return generateAndDestroy(['route', 'index', '--pod'], { + afterDestroy: function() { + // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38 + files.shift(); + }, + files: files, + }); + }); + + it('route application --pod', function() { + return generateAndDestroy(['route', 'foo'], { + afterGenerate: function(){ + return remove(path.join('app', 'templates', 'application.hbs')) + .then(function() { + var files = [ + { + file: 'app/router.js', + doesNotContain: "this.route('application');" + } + ]; + + return generateAndDestroy(['route', 'application', '--pod'], { + skipInit: true, + afterDestroy: function() { + // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38 + files.shift(); + }, + files: files, + }); + }); + } + }); + }); + + it('route basic --pod isn\'t added to router', function() { + var files = [ + { + file: 'app/router.js', + doesNotContain: "this.route('basic');" + }, + { + file: 'app/basic/route.js' + } + ]; + + return generateAndDestroy(['route', 'basic', '--pod'], { + afterDestroy: function() { + // remove `app/router.js` to work around https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/38 + files.shift(); + }, + files: files, + }); + }); + + it('route-test foo', function() { + return generateAndDestroy(['route-test', 'foo'], { + files: [ + { + file: 'tests/unit/routes/foo-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('route:foo'" + ] + } + ] + }); + }); + + it('in-addon route-test foo', function() { + return generateAndDestroy(['route-test', 'foo'], { + target: 'addon', + files: [ + { + file: 'tests/unit/routes/foo-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('route:foo'" + ] + }, + { + file: 'app/route-test/foo.js', + exists: false + } + ] + }); + }); + + + it('dummy route-test foo', function() { + return generateAndDestroy(['route-test', 'foo'], { + target: 'addon', + files: [ + { + file: 'tests/unit/routes/foo-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('route:foo'" + ] + }, + { + file: 'app/route-test/foo.js', + exists: false + } + ] + }); + }); + + it('route-test foo for mocha', function() { + return generateAndDestroy(['route-test', 'foo'], { + packages: [ + { name: 'ember-cli-qunit', delete: true }, + { name: 'ember-cli-mocha', dev: true } + ], + files: [ + { + file: 'tests/unit/routes/foo-test.js', + contains: [ + "import { describeModule, it } from 'ember-mocha';", + "describeModule('route:foo', 'Unit | Route | foo'" + ] + } + ] + }); + }); +}); diff --git a/node-tests/blueprints/service-test.js b/node-tests/blueprints/service-test.js new file mode 100644 index 0000000..d5fbe0d --- /dev/null +++ b/node-tests/blueprints/service-test.js @@ -0,0 +1,247 @@ +'use strict'; + +var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup'); +var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper'); +var generateAndDestroy = BlueprintHelpers.generateAndDestroy; + +describe('Acceptance: ember generate and destroy service', function() { + setupTestHooks(this); + + it('service foo', function() { + return generateAndDestroy(['service', 'foo'], { + files: [ + { + file: 'app/services/foo.js', + contains: [ + "import Ember from 'ember';", + 'export default Ember.Service.extend({\n});' + ] + }, + { + file: 'tests/unit/services/foo-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('service:foo'" + ] + } + ] + }); + }); + + it('service foo/bar', function() { + return generateAndDestroy(['service', 'foo/bar'], { + files: [ + { + file: 'app/services/foo/bar.js', + contains: [ + "import Ember from 'ember';", + 'export default Ember.Service.extend({\n});' + ] + }, + { + file: 'tests/unit/services/foo/bar-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('service:foo/bar'" + ] + } + ] + }); + }); + it('in-addon service foo', function() { + return generateAndDestroy(['service', 'foo'], { + target: 'addon', + files: [ + { + file: 'addon/services/foo.js', + contains: [ + "import Ember from 'ember';", + 'export default Ember.Service.extend({\n});' + ] + }, + { + file: 'app/services/foo.js', + contains: [ + "export { default } from 'my-addon/services/foo';" + ] + }, + { + file: 'tests/unit/services/foo-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('service:foo'" + ] + } + ] + }); + }); + + it('in-addon service foo/bar', function() { + return generateAndDestroy(['service', 'foo/bar'], { + target: 'addon', + files: [ + { + file: 'addon/services/foo/bar.js', + contains: [ + "import Ember from 'ember';", + 'export default Ember.Service.extend({\n});' + ] + }, + { + file: 'app/services/foo/bar.js', + contains: [ + "export { default } from 'my-addon/services/foo/bar';" + ] + }, + { + file: 'tests/unit/services/foo/bar-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('service:foo/bar'" + ] + } + ] + }); + }); +/** +* Pod tests +* +*/ + + it('service foo --pod', function() { + return generateAndDestroy(['service', 'foo', '--pod'], { + files: [ + { + file: 'app/foo/service.js', + contains: [ + "import Ember from 'ember';", + 'export default Ember.Service.extend({\n});' + ] + }, + { + file: 'tests/unit/foo/service-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('service:foo'" + ] + } + ] + }); + }); + + it('service foo/bar --pod', function() { + return generateAndDestroy(['service', 'foo/bar', '--pod'], { + files: [ + { + file: 'app/foo/bar/service.js', + contains: [ + "import Ember from 'ember';", + 'export default Ember.Service.extend({\n});' + ] + }, + { + file: 'tests/unit/foo/bar/service-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('service:foo/bar'" + ] + } + ] + }); + }); + + it('service foo --pod podModulePrefix', function() { + return generateAndDestroy(['service', 'foo', '--pod'], { + podModulePrefix: true, + files: [ + { + file: 'app/pods/foo/service.js', + contains: [ + "import Ember from 'ember';", + 'export default Ember.Service.extend({\n});' + ] + }, + { + file: 'tests/unit/pods/foo/service-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('service:foo'" + ] + } + ] + }); + }); + + it('service foo/bar --pod podModulePrefix', function() { + return generateAndDestroy(['service', 'foo/bar', '--pod'], { + podModulePrefix: true, + files: [ + { + file: 'app/pods/foo/bar/service.js', + contains: [ + "import Ember from 'ember';", + 'export default Ember.Service.extend({\n});' + ] + }, + { + file: 'tests/unit/pods/foo/bar/service-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('service:foo/bar'" + ] + } + ] + }); + }); + + it('service-test foo', function() { + return generateAndDestroy(['service-test', 'foo'], { + files: [ + { + file: 'tests/unit/services/foo-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('service:foo'" + ] + } + ] + }); + }); + + it('in-addon service-test foo', function() { + return generateAndDestroy(['service-test', 'foo'], { + target: 'addon', + files: [ + { + file: 'tests/unit/services/foo-test.js', + contains: [ + "import { moduleFor, test } from 'ember-qunit';", + "moduleFor('service:foo'" + ] + }, + { + file: 'app/service-test/foo.js', + exists: false + } + ] + }); + }); + + it('service-test foo for mocha', function() { + return generateAndDestroy(['service-test', 'foo'], { + packages: [ + { name: 'ember-cli-qunit', delete: true }, + { name: 'ember-cli-mocha', dev: true } + ], + files: [ + { + file: 'tests/unit/services/foo-test.js', + contains: [ + "import { describeModule, it } from 'ember-mocha';", + "describeModule('service:foo', 'Unit | Service | foo'" + ] + } + ] + }); + }); +}); diff --git a/node-tests/blueprints/template-test.js b/node-tests/blueprints/template-test.js new file mode 100644 index 0000000..3109bd2 --- /dev/null +++ b/node-tests/blueprints/template-test.js @@ -0,0 +1,118 @@ +'use strict'; + +var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup'); +var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper'); +var generateAndDestroy = BlueprintHelpers.generateAndDestroy; + +describe('Acceptance: ember generate and destroy template', function() { + setupTestHooks(this); + + it('template foo', function() { + return generateAndDestroy(['template', 'foo'], { + files: [ + { file: 'app/templates/foo.hbs', isEmpty: true } + ] + }); + }); + + it('template foo/bar', function() { + return generateAndDestroy(['template', 'foo/bar'], { + files: [ + { file: 'app/templates/foo/bar.hbs', isEmpty: true } + ] + }); + }); + + it('template foo --pod', function() { + return generateAndDestroy(['template', 'foo'], { + usePods: true, + files: [ + { file: 'app/foo/template.hbs', isEmpty: true } + ] + }); + }); + + it('template foo/bar --pod', function() { + return generateAndDestroy(['template', 'foo/bar'], { + usePods: true, + files: [ + { file: 'app/foo/bar/template.hbs', isEmpty: true } + ] + }); + }); + + it('template foo --pod podModulePrefix', function() { + return generateAndDestroy(['template', 'foo'], { + usePods: true, + podModulePrefix: true, + files: [ + { file: 'app/pods/foo/template.hbs', isEmpty: true } + ] + }); + }); + + it('template foo/bar --pod podModulePrefix', function() { + return generateAndDestroy(['template', 'foo/bar'], { + usePods: true, + podModulePrefix: true, + files: [ + { file: 'app/pods/foo/bar/template.hbs', isEmpty: true } + ] + }); + }); + + it('in-addon template foo', function() { + return generateAndDestroy(['template', 'foo'], { + target: 'addon', + files: [ + { file: 'addon/templates/foo.hbs', isEmpty: true } + ] + }); + }); + + it('in-addon template foo/bar', function() { + return generateAndDestroy(['template', 'foo/bar'], { + target: 'addon', + files: [ + { file: 'addon/templates/foo/bar.hbs', isEmpty: true } + ] + }); + }); + + it('dummy template foo', function() { + return generateAndDestroy(['template', 'foo', '--dummy'], { + target: 'addon', + files: [ + { file: 'tests/dummy/app/templates/foo.hbs', isEmpty: true } + ] + }); + }); + + it('dummy template foo/bar', function() { + return generateAndDestroy(['template', 'foo/bar', '--dummy'], { + target: 'addon', + files: [ + { file: 'tests/dummy/app/templates/foo/bar.hbs', isEmpty: true } + ] + }); + }); + + it('in-repo-addon template foo', function() { + return generateAndDestroy(['template', 'foo', '--in-repo-addon=my-addon'], { + target: 'inRepoAddon', + files: [ + { file: 'lib/my-addon/addon/templates/foo.hbs', isEmpty: true } + ] + }); + }); + + it('in-repo-addon template foo/bar', function() { + return generateAndDestroy(['template', 'foo/bar', '--in-repo-addon=my-addon'], { + target: 'inRepoAddon', + files: [ + { file: 'lib/my-addon/addon/templates/foo/bar.hbs', isEmpty: true } + ] + }); + }); + +}); diff --git a/node-tests/blueprints/test-helper-test.js b/node-tests/blueprints/test-helper-test.js new file mode 100644 index 0000000..8318642 --- /dev/null +++ b/node-tests/blueprints/test-helper-test.js @@ -0,0 +1,23 @@ +'use strict'; + +var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup'); +var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper'); +var generateAndDestroy = BlueprintHelpers.generateAndDestroy; + +describe('Acceptance: ember generate and destroy test-helper', function() { + setupTestHooks(this); + + it('test-helper foo', function() { + return generateAndDestroy(['test-helper', 'foo'], { + files: [ + { + file: 'tests/helpers/foo.js', + contains: [ + "import Ember from 'ember';", + 'export default Ember.Test.registerAsyncHelper(\'foo\', function(app) {\n\n}' + ] + } + ] + }); + }); +}); diff --git a/node-tests/blueprints/util-test.js b/node-tests/blueprints/util-test.js new file mode 100644 index 0000000..422ee9e --- /dev/null +++ b/node-tests/blueprints/util-test.js @@ -0,0 +1,207 @@ +'use strict'; + +var setupTestHooks = require('ember-cli-blueprint-test-helpers/lib/helpers/setup'); +var BlueprintHelpers = require('ember-cli-blueprint-test-helpers/lib/helpers/blueprint-helper'); +var generateAndDestroy = BlueprintHelpers.generateAndDestroy; + +describe('Acceptance: ember generate and destroy util', function() { + setupTestHooks(this); + + it('util foo-bar', function() { + return generateAndDestroy(['util', 'foo-bar'], { + files: [ + { + file: 'app/utils/foo-bar.js', + contains: 'export default function fooBar() {\n' + + ' return true;\n' + + '}' + }, + { + file: 'tests/unit/utils/foo-bar-test.js', + contains: [ + "import fooBar from 'my-app/utils/foo-bar';" + ] + } + ] + }); + }); + + it('util foo-bar/baz', function() { + return generateAndDestroy(['util', 'foo/bar-baz'], { + files: [ + { + file: 'app/utils/foo/bar-baz.js', + contains: 'export default function fooBarBaz() {\n' + + ' return true;\n' + + '}' + }, + { + file: 'tests/unit/utils/foo/bar-baz-test.js', + contains: [ + "import fooBarBaz from 'my-app/utils/foo/bar-baz';" + ] + } + ] + }); + }); + + it('in-addon util foo-bar', function() { + return generateAndDestroy(['util', 'foo-bar'], { + target: 'addon', + files: [ + { + file: 'addon/utils/foo-bar.js', + contains: 'export default function fooBar() {\n' + + ' return true;\n' + + '}' + }, + { + file: 'app/utils/foo-bar.js', + contains: [ + "export { default } from 'my-addon/utils/foo-bar';" + ] + }, + { + file: 'tests/unit/utils/foo-bar-test.js', + contains: [ + "import fooBar from 'dummy/utils/foo-bar';" + ] + } + ] + }); + }); + + it('in-addon util foo-bar/baz', function() { + return generateAndDestroy(['util', 'foo/bar-baz'], { + target: 'addon', + files: [ + { + file: 'addon/utils/foo/bar-baz.js', + contains: 'export default function fooBarBaz() {\n' + + ' return true;\n' + + '}' + }, + { + file: 'app/utils/foo/bar-baz.js', + contains: [ + "export { default } from 'my-addon/utils/foo/bar-baz';" + ] + }, + { + file: 'tests/unit/utils/foo/bar-baz-test.js', + contains: [ + "import fooBarBaz from 'dummy/utils/foo/bar-baz';" + ] + } + ] + }); + }); +/** +* Pod tests +* +*/ + + it('util foo-bar --pod', function() { + return generateAndDestroy(['util', 'foo-bar', '--pod'], { + files: [ + { + file: 'app/utils/foo-bar.js', + contains: 'export default function fooBar() {\n' + + ' return true;\n' + + '}' + }, + { + file: 'tests/unit/utils/foo-bar-test.js', + contains: [ + "import fooBar from 'my-app/utils/foo-bar';" + ] + } + ] + }); + }); + + it('util foo-bar --pod podModulePrefix', function() { + return generateAndDestroy(['util', 'foo-bar', '--pod'], { + podModulePrefix: true, + files: [ + { + file: 'app/utils/foo-bar.js', + contains: 'export default function fooBar() {\n' + + ' return true;\n' + + '}' + }, + { + file: 'tests/unit/utils/foo-bar-test.js', + contains: [ + "import fooBar from 'my-app/utils/foo-bar';" + ] + } + ] + }); + }); + + it('util foo-bar/baz --pod', function() { + return generateAndDestroy(['util', 'foo/bar-baz', '--pod'], { + files: [ + { + file: 'app/utils/foo/bar-baz.js', + contains: 'export default function fooBarBaz() {\n' + + ' return true;\n' + + '}' + }, + { + file: 'tests/unit/utils/foo/bar-baz-test.js', + contains: [ + "import fooBarBaz from 'my-app/utils/foo/bar-baz';" + ] + } + ] + }); + }); + + it('util-test foo-bar', function() { + return generateAndDestroy(['util-test', 'foo-bar'], { + files: [ + { + file: 'tests/unit/utils/foo-bar-test.js', + contains: [ + "import fooBar from 'my-app/utils/foo-bar';" + ] + } + ] + }); + }); + + it('in-addon util-test foo-bar', function() { + return generateAndDestroy(['util-test', 'foo-bar'], { + target: 'addon', + files: [ + { + file: 'tests/unit/utils/foo-bar-test.js', + contains: [ + "import fooBar from 'dummy/utils/foo-bar';" + ] + } + ] + }); + }); + + it('util-test foo-bar for mocha', function() { + return generateAndDestroy(['util-test', 'foo-bar'], { + packages: [ + { name: 'ember-cli-qunit', delete: true }, + { name: 'ember-cli-mocha', dev: true } + ], + files: [ + { + file: 'tests/unit/utils/foo-bar-test.js', + contains: [ + "import { describe, it } from 'mocha';", + "import fooBar from 'my-app/utils/foo-bar';", + "describe('Unit | Utility | foo bar', function() {" + ] + } + ] + }); + }); +});