From 7a435127f2841a052095c1d42a7b629900ea0120 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Thu, 3 Mar 2016 09:32:39 +0100 Subject: [PATCH 01/21] Add blueprint dependencies --- package.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/package.json b/package.json index 348a28e0c30..223987d3f34 100644 --- a/package.json +++ b/package.json @@ -45,5 +45,13 @@ "serve-static": "^1.10.0", "simple-dom": "^0.2.7", "testem": "^1.0.0-rc.3" + }, + "dependencies": { + "ember-cli-get-component-path-option": "^1.0.0", + "ember-cli-normalize-entity-name": "^1.0.0", + "ember-cli-path-utils": "^1.0.0", + "ember-cli-string-utils": "^1.0.0", + "ember-cli-test-info": "^1.0.0", + "ember-cli-valid-component-name": "^1.0.0" } } From eab2871c06ef111cc7389e10b1206b96d77f2ac3 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Mon, 22 Feb 2016 17:38:17 +0100 Subject: [PATCH 02/21] Add "ember-cli-blueprint-test-helpers" dev dependency --- .npmignore | 1 + .travis.yml | 1 + bin/run-tests.js | 5 ++ .../fixtures/addon/package/package.json | 22 ++++++ node-tests/fixtures/app/package/package.json | 13 ++++ node-tests/nodetest-runner.js | 74 +++++++++++++++++++ package.json | 8 +- 7 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 .npmignore create mode 100644 node-tests/fixtures/addon/package/package.json create mode 100644 node-tests/fixtures/app/package/package.json create mode 100644 node-tests/nodetest-runner.js diff --git a/.npmignore b/.npmignore new file mode 100644 index 00000000000..0ba0fc1c85c --- /dev/null +++ b/.npmignore @@ -0,0 +1 @@ +node-tests/ diff --git a/.travis.yml b/.travis.yml index 07a64fac025..bc1118c03f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -73,4 +73,5 @@ env: - TEST_SUITE=built-tests EMBER_ENV=production DISABLE_JSCS=true DISABLE_JSHINT=true - TEST_SUITE=old-jquery-and-extend-prototypes - TEST_SUITE=node DISABLE_JSCS=true DISABLE_JSHINT=true + - TEST_SUITE=blueprints - TEST_SUITE=sauce diff --git a/bin/run-tests.js b/bin/run-tests.js index 22503e01ecc..a3b56d24c14 100755 --- a/bin/run-tests.js +++ b/bin/run-tests.js @@ -158,6 +158,11 @@ switch (process.env.TEST_SUITE) { console.log('suite: node'); require('./run-node-tests'); return; + case 'blueprints': + console.log('suite: blueprints'); + require('../node-tests/nodetest-runner'); + server.close(); + return; case 'sauce': console.log('suite: sauce'); require('./run-sauce-tests'); diff --git a/node-tests/fixtures/addon/package/package.json b/node-tests/fixtures/addon/package/package.json new file mode 100644 index 00000000000..bef04646b4b --- /dev/null +++ b/node-tests/fixtures/addon/package/package.json @@ -0,0 +1,22 @@ +{ + "name": "my-addon", + "version": "0.0.0", + "description": "Addon fixture package for ember-cli-blueprint-test-helpers", + "engines": { + "node": ">= 0.10.0" + }, + "devDependencies": { + "ember-cli": "*", + "ember": "*" + }, + "keywords": [ + "ember-addon" + ], + "dependencies": { + "ember-cli-htmlbars": "*", + "ember-cli-babel": "*" + }, + "ember-addon": { + "configPath": "tests/dummy/config" + } +} diff --git a/node-tests/fixtures/app/package/package.json b/node-tests/fixtures/app/package/package.json new file mode 100644 index 00000000000..0039eae9d41 --- /dev/null +++ b/node-tests/fixtures/app/package/package.json @@ -0,0 +1,13 @@ +{ + "name": "my-app", + "version": "0.0.0", + "description": "App fixture package for ember-cli-blueprint-test-helpers", + "private": true, + "engines": { + "node": ">= 0.10.0" + }, + "devDependencies": { + "ember-cli": "*", + "ember": "*" + } +} diff --git a/node-tests/nodetest-runner.js b/node-tests/nodetest-runner.js new file mode 100644 index 00000000000..05b1299f382 --- /dev/null +++ b/node-tests/nodetest-runner.js @@ -0,0 +1,74 @@ +'use strict'; + +var glob = require('glob'); +var Mocha = require('mocha'); +var Promise = require('ember-cli/lib/ext/promise'); +var rimraf = require('rimraf'); +var mochaOnlyDetector = require('mocha-only-detector'); + +if (process.env.EOLNEWLINE) { + require('os').EOL = '\n'; +} + +rimraf.sync('.node_modules-tmp'); +rimraf.sync('.bower_components-tmp'); + +var root = 'node-tests/{blueprints,acceptance,unit}'; +var _checkOnlyInTests = Promise.denodeify(mochaOnlyDetector.checkFolder.bind(null, root + '/**/*{-test}.js')); +var optionOrFile = process.argv[2]; +var mocha = new Mocha({ + timeout: 5000, + reporter: 'spec' +}); +var testFiles = glob.sync(root + '/**/*-test.js'); +/*var jshintPosition = testFiles.indexOf('tests/unit/jshint-test.js'); +var jshint = testFiles.splice(jshintPosition, 1); + +testFiles = jshint.concat(testFiles); +*/ +if (optionOrFile === 'all') { + addFiles(mocha, testFiles); + addFiles(mocha, 'node-tests/**/*-test.js'); + addFiles(mocha, '/**/*-test-slow.js'); +} else if (process.argv.length > 2) { + addFiles(mocha, process.argv.slice(2)); +} else { + addFiles(mocha, testFiles); +} + +function addFiles(mocha, files) { + files = (typeof files === 'string') ? glob.sync(root + files) : files; + files.forEach(mocha.addFile.bind(mocha)); +} + +function checkOnlyInTests() { + console.log('Verifing `.only` in tests'); + return _checkOnlyInTests().then(function() { + console.log('No `.only` found'); + }); +} + +function runMocha() { + mocha.run(function(failures) { + process.on('exit', function() { + process.exit(failures); + }); + }); +} + +function ciVerificationStep() { + if (process.env.CI === 'true') { + return checkOnlyInTests(); + } else { + return Promise.resolve(); + } +} + +ciVerificationStep() + .then(function() { + runMocha(); + }) + .catch(function(error) { + console.error(error); + process.exit(1); + }); diff --git a/package.json b/package.json index 223987d3f34..a836f409132 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "test": "bin/run-tests.js", "test:sauce": "bin/run-sauce-tests.js", "test:testem": "testem -f testem.dist.json", + "test:blueprints": "node node-tests/nodetest-runner.js", "start": "ember serve", "docs": "ember ember-cli-yuidoc", "sauce:launch": "ember sauce:launch" @@ -27,7 +28,9 @@ "broccoli-stew": "^1.2.0", "chalk": "^0.5.1", "ember-cli": "^2.2.0-beta.2", + "ember-cli-blueprint-test-helpers": "^0.9.0", "ember-cli-dependency-checker": "^1.2.0", + "ember-cli-internal-test-helpers": "^0.7.0", "ember-cli-sauce": "^1.4.2", "ember-cli-yuidoc": "0.7.0", "ember-publisher": "0.0.7", @@ -36,10 +39,13 @@ "finalhandler": "^0.4.0", "github": "^0.2.3", "glimmer-engine": "tildeio/glimmer#4e13bc1", - "glob": "~4.3.2", + "glob": "^5.0.13", "htmlbars": "0.14.14", + "mocha": "^2.4.5", + "mocha-only-detector": "0.0.2", "qunit-extras": "^1.4.0", "qunitjs": "^1.20.0", + "rimraf": "^2.5.2", "route-recognizer": "0.1.5", "rsvp": "~3.1.0", "serve-static": "^1.10.0", From 5968d1df1e6abefe83daa1a45f3f06f64d37a16c Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Mon, 22 Feb 2016 17:40:09 +0100 Subject: [PATCH 03/21] blueprints: Import "template" blueprint from "ember-cli" --- .../files/__root__/__path__/__name__.hbs | 0 blueprints/template/index.js | 5 + node-tests/blueprints/template-test.js | 118 ++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 blueprints/template/files/__root__/__path__/__name__.hbs create mode 100644 blueprints/template/index.js create mode 100644 node-tests/blueprints/template-test.js diff --git a/blueprints/template/files/__root__/__path__/__name__.hbs b/blueprints/template/files/__root__/__path__/__name__.hbs new file mode 100644 index 00000000000..e69de29bb2d diff --git a/blueprints/template/index.js b/blueprints/template/index.js new file mode 100644 index 00000000000..571f9cc9d8b --- /dev/null +++ b/blueprints/template/index.js @@ -0,0 +1,5 @@ +/*jshint node:true*/ + +module.exports = { + description: 'Generates a template.' +}; diff --git a/node-tests/blueprints/template-test.js b/node-tests/blueprints/template-test.js new file mode 100644 index 00000000000..3109bd2ee17 --- /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 } + ] + }); + }); + +}); From 9722648ea2c587db3fc036e23a8496f21018fe62 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Thu, 3 Mar 2016 08:48:26 +0100 Subject: [PATCH 04/21] blueprints: Import "acceptance-test" blueprint from "ember-cli" --- .../files/tests/acceptance/__name__-test.js | 12 +++ blueprints/acceptance-test/index.js | 20 +++++ node-tests/blueprints/acceptance-test-test.js | 75 +++++++++++++++++++ 3 files changed, 107 insertions(+) create mode 100644 blueprints/acceptance-test/files/tests/acceptance/__name__-test.js create mode 100644 blueprints/acceptance-test/index.js create mode 100644 node-tests/blueprints/acceptance-test-test.js diff --git a/blueprints/acceptance-test/files/tests/acceptance/__name__-test.js b/blueprints/acceptance-test/files/tests/acceptance/__name__-test.js new file mode 100644 index 00000000000..abbcab2497f --- /dev/null +++ b/blueprints/acceptance-test/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/acceptance-test/index.js b/blueprints/acceptance-test/index.js new file mode 100644 index 00000000000..38f85563c0b --- /dev/null +++ b/blueprints/acceptance-test/index.js @@ -0,0 +1,20 @@ +/*jshint node:true*/ + +var testInfo = require('ember-cli-test-info'); +var pathUtil = require('ember-cli-path-utils'); +var stringUtils = require('ember-cli-string-utils'); + +module.exports = { + 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); + } + return { + testFolderRoot: testFolderRoot, + friendlyTestName: testInfo.name(options.entity.name, 'Acceptance', null) + }; + } +}; diff --git a/node-tests/blueprints/acceptance-test-test.js b/node-tests/blueprints/acceptance-test-test.js new file mode 100644 index 00000000000..78a35319499 --- /dev/null +++ b/node-tests/blueprints/acceptance-test-test.js @@ -0,0 +1,75 @@ +'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 + } + ] + }); + }); + +}); From 3332020bd34272c3e473c6a5d8ab3a155b3148c1 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Thu, 3 Mar 2016 18:59:17 +0100 Subject: [PATCH 05/21] blueprints: Import "component" blueprint from "ember-cli" --- .../tests/__testType__/__path__/__test__.js | 31 + blueprints/component-test/index.js | 67 ++ .../files/__root__/__path__/__name__.js | 4 + .../__templatepath__/__templatename__.hbs | 1 + blueprints/component/index.js | 76 ++ node-tests/blueprints/component-test.js | 1037 +++++++++++++++++ 6 files changed, 1216 insertions(+) create mode 100644 blueprints/component-test/files/tests/__testType__/__path__/__test__.js create mode 100644 blueprints/component-test/index.js create mode 100644 blueprints/component/files/__root__/__path__/__name__.js create mode 100644 blueprints/component/files/__root__/__templatepath__/__templatename__.hbs create mode 100644 blueprints/component/index.js create mode 100644 node-tests/blueprints/component-test.js diff --git a/blueprints/component-test/files/tests/__testType__/__path__/__test__.js b/blueprints/component-test/files/tests/__testType__/__path__/__test__.js new file mode 100644 index 00000000000..faf52d9996c --- /dev/null +++ b/blueprints/component-test/files/tests/__testType__/__path__/__test__.js @@ -0,0 +1,31 @@ +import { moduleForComponent, test } from 'ember-qunit';<% if (testType === 'integration') { %> +import hbs from 'htmlbars-inline-precompile';<% } %> + +moduleForComponent('<%= 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<% } %> +}); + +test('it renders', function(assert) { + <% 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: + this.render(hbs` + {{#<%= componentPathName %>}} + template block text + {{/<%= componentPathName %>}} + `); + + assert.equal(this.$().text().trim(), 'template block text');<% } else if(testType === 'unit') { %> + // Creates the component instance + /*let component =*/ this.subject(); + // Renders the component to the page + this.render(); + assert.equal(this.$().text().trim(), '');<% } %> +}); diff --git a/blueprints/component-test/index.js b/blueprints/component-test/index.js new file mode 100644 index 00000000000..2d4d80435fd --- /dev/null +++ b/blueprints/component-test/index.js @@ -0,0 +1,67 @@ +/*jshint node:true*/ + +var path = require('path'); +var testInfo = require('ember-cli-test-info'); +var stringUtil = require('ember-cli-string-utils'); +var isPackageMissing = require('ember-cli-is-package-missing'); +var getPathOption = require('ember-cli-get-component-path-option'); + +module.exports = { + description: 'Generates a component integration or unit test.', + + availableOptions: [ + { + name: 'test-type', + type: ['integration', 'unit'], + default: 'integration', + aliases:[ + { 'i': 'integration'}, + { 'u': 'unit'}, + { 'integration': 'integration' }, + { 'unit': 'unit' } + ] + } + ], + + fileMapTokens: function() { + return { + __testType__: function(options) { + return options.locals.testType || 'integration'; + }, + __path__: function(options) { + if (options.pod) { + return path.join(options.podPath, options.locals.path, options.dasherizedModuleName); + } + return 'components'; + } + }; + }, + 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'); + + 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'); + } + + return { + path: getPathOption(options), + testType: testType, + 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/files/__root__/__path__/__name__.js b/blueprints/component/files/__root__/__path__/__name__.js new file mode 100644 index 00000000000..fb1798c77cb --- /dev/null +++ b/blueprints/component/files/__root__/__path__/__name__.js @@ -0,0 +1,4 @@ +import Ember from 'ember'; +<%= importTemplate %> +export default Ember.Component.extend({<%= contents %> +}); diff --git a/blueprints/component/files/__root__/__templatepath__/__templatename__.hbs b/blueprints/component/files/__root__/__templatepath__/__templatename__.hbs new file mode 100644 index 00000000000..889d9eeadc1 --- /dev/null +++ b/blueprints/component/files/__root__/__templatepath__/__templatename__.hbs @@ -0,0 +1 @@ +{{yield}} diff --git a/blueprints/component/index.js b/blueprints/component/index.js new file mode 100644 index 00000000000..bcfaf3c6b8b --- /dev/null +++ b/blueprints/component/index.js @@ -0,0 +1,76 @@ +/*jshint node:true*/ + +var stringUtil = require('ember-cli-string-utils'); +var pathUtil = require('ember-cli-path-utils'); +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'); + +module.exports = { + description: 'Generates a component. Name must contain a hyphen.', + + availableOptions: [ + { + name: 'path', + type: String, + default: 'components', + aliases:[ + {'no-path': ''} + ] + } + ], + + fileMapTokens: function() { + return { + __path__: function(options) { + if (options.pod) { + return path.join(options.podPath, options.locals.path, options.dasherizedModuleName); + } + return 'components'; + }, + __templatepath__: function(options) { + if (options.pod) { + return path.join(options.podPath, options.locals.path, options.dasherizedModuleName); + } + return 'templates/components'; + }, + __templatename__: function(options) { + if (options.pod) { + return 'template'; + } + return options.dasherizedModuleName; + } + }; + }, + + normalizeEntityName: function(entityName) { + entityName = normalizeEntityName(entityName); + + return validComponentName(entityName); + }, + + locals: function(options) { + var templatePath = ''; + var importTemplate = ''; + var contents = ''; + // if we're in an addon, build import statement + if (options.project.isEmberCLIAddon() || options.inRepoAddon && !options.inDummy) { + if(options.pod) { + templatePath = './template'; + } else { + templatePath = pathUtil.getRelativeParentPath(options.entity.name) + + 'templates/components/' + stringUtil.dasherize(options.entity.name); + } + importTemplate = 'import layout from \'' + templatePath + '\';\n'; + contents = '\n layout'; + } + + return { + importTemplate: importTemplate, + contents: contents, + path: getPathOption(options) + }; + } +}; diff --git a/node-tests/blueprints/component-test.js b/node-tests/blueprints/component-test.js new file mode 100644 index 00000000000..44ff5decbca --- /dev/null +++ b/node-tests/blueprints/component-test.js @@ -0,0 +1,1037 @@ +'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 + } + ] + }); + }); + +}); From 5619d3c2adbfeebbb28568f92c1b65f500d66abe Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Thu, 3 Mar 2016 19:00:09 +0100 Subject: [PATCH 06/21] blueprints: Import "component-addon" blueprint from "ember-cli" --- .../files/__root__/__path__/__name__.js | 1 + blueprints/component-addon/index.js | 56 +++++++++++++++++++ node-tests/blueprints/component-addon-test.js | 23 ++++++++ 3 files changed, 80 insertions(+) create mode 100644 blueprints/component-addon/files/__root__/__path__/__name__.js create mode 100644 blueprints/component-addon/index.js create mode 100644 node-tests/blueprints/component-addon-test.js diff --git a/blueprints/component-addon/files/__root__/__path__/__name__.js b/blueprints/component-addon/files/__root__/__path__/__name__.js new file mode 100644 index 00000000000..71a8b71c1c6 --- /dev/null +++ b/blueprints/component-addon/files/__root__/__path__/__name__.js @@ -0,0 +1 @@ +export { default } from '<%= modulePath %>'; \ No newline at end of file diff --git a/blueprints/component-addon/index.js b/blueprints/component-addon/index.js new file mode 100644 index 00000000000..626e24e1eba --- /dev/null +++ b/blueprints/component-addon/index.js @@ -0,0 +1,56 @@ +/*jshint node:true*/ + +var stringUtil = require('ember-cli-string-utils'); +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'); + +module.exports = { + description: 'Generates a component. Name must contain a hyphen.', + + fileMapTokens: function() { + return { + __path__: function(options) { + if (options.pod) { + return path.join(options.podPath, options.locals.path, options.dasherizedModuleName); + } + return 'components'; + }, + __name__: function(options) { + if (options.pod) { + return 'component'; + } + return options.dasherizedModuleName; + }, + __root__: function(options) { + if (options.inRepoAddon) { + return path.join('lib', options.inRepoAddon, 'app'); + } + return 'app'; + } + }; + }, + + normalizeEntityName: function(entityName) { + entityName = normalizeEntityName(entityName); + + return validComponentName(entityName); + }, + + 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 importPathName = [addonName, 'components', fileName].join('/'); + + if (options.pod) { + importPathName = [addonName, 'components', fileName,'component'].join('/'); + } + + return { + modulePath: importPathName, + path: getPathOption(options) + }; + } +}; diff --git a/node-tests/blueprints/component-addon-test.js b/node-tests/blueprints/component-addon-test.js new file mode 100644 index 00000000000..447717b3c50 --- /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';" + } + ] + }); + }); +}); From b695cb0d14f9f6871f56539becaf83d7225efeaf Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Thu, 3 Mar 2016 19:04:30 +0100 Subject: [PATCH 07/21] blueprints: Import "controller" blueprint from "ember-cli" --- .../files/tests/unit/__path__/__test__.js | 12 + blueprints/controller-test/index.js | 12 + .../files/__root__/__path__/__name__.js | 4 + blueprints/controller/index.js | 5 + node-tests/blueprints/controller-test.js | 329 ++++++++++++++++++ 5 files changed, 362 insertions(+) create mode 100644 blueprints/controller-test/files/tests/unit/__path__/__test__.js create mode 100644 blueprints/controller-test/index.js create mode 100644 blueprints/controller/files/__root__/__path__/__name__.js create mode 100644 blueprints/controller/index.js create mode 100644 node-tests/blueprints/controller-test.js diff --git a/blueprints/controller-test/files/tests/unit/__path__/__test__.js b/blueprints/controller-test/files/tests/unit/__path__/__test__.js new file mode 100644 index 00000000000..db26bfa5579 --- /dev/null +++ b/blueprints/controller-test/files/tests/unit/__path__/__test__.js @@ -0,0 +1,12 @@ +import { moduleFor, test } from 'ember-qunit'; + +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) { + let controller = this.subject(); + assert.ok(controller); +}); diff --git a/blueprints/controller-test/index.js b/blueprints/controller-test/index.js new file mode 100644 index 00000000000..1d11685752d --- /dev/null +++ b/blueprints/controller-test/index.js @@ -0,0 +1,12 @@ +/*jshint node:true*/ + +var testInfo = require('ember-cli-test-info'); + +module.exports = { + description: 'Generates a controller unit test.', + locals: function(options) { + return { + friendlyTestDescription: testInfo.description(options.entity.name, 'Unit', 'Controller') + }; + } +}; diff --git a/blueprints/controller/files/__root__/__path__/__name__.js b/blueprints/controller/files/__root__/__path__/__name__.js new file mode 100644 index 00000000000..55ff9aa587a --- /dev/null +++ b/blueprints/controller/files/__root__/__path__/__name__.js @@ -0,0 +1,4 @@ +import Ember from 'ember'; + +export default Ember.Controller.extend({ +}); diff --git a/blueprints/controller/index.js b/blueprints/controller/index.js new file mode 100644 index 00000000000..cc81d473736 --- /dev/null +++ b/blueprints/controller/index.js @@ -0,0 +1,5 @@ +/*jshint node:true*/ + +module.exports = { + description: 'Generates a controller.' +}; diff --git a/node-tests/blueprints/controller-test.js b/node-tests/blueprints/controller-test.js new file mode 100644 index 00000000000..a00d7008351 --- /dev/null +++ b/node-tests/blueprints/controller-test.js @@ -0,0 +1,329 @@ +'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'" + ] + } + ] + }); + }); + +}); From 5d64883b87b1fce2591ed3cb1b4377f021f6b00e Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Thu, 3 Mar 2016 19:19:23 +0100 Subject: [PATCH 08/21] blueprints: Import "util" blueprint from "ember-cli" --- .../files/tests/unit/utils/__name__-test.js | 10 + blueprints/util-test/index.js | 14 ++ .../util/files/__root__/utils/__name__.js | 3 + blueprints/util/index.js | 5 + node-tests/blueprints/util-test.js | 189 ++++++++++++++++++ 5 files changed, 221 insertions(+) create mode 100644 blueprints/util-test/files/tests/unit/utils/__name__-test.js create mode 100644 blueprints/util-test/index.js create mode 100644 blueprints/util/files/__root__/utils/__name__.js create mode 100644 blueprints/util/index.js create mode 100644 node-tests/blueprints/util-test.js diff --git a/blueprints/util-test/files/tests/unit/utils/__name__-test.js b/blueprints/util-test/files/tests/unit/utils/__name__-test.js new file mode 100644 index 00000000000..287fb465a45 --- /dev/null +++ b/blueprints/util-test/files/tests/unit/utils/__name__-test.js @@ -0,0 +1,10 @@ +import <%= camelizedModuleName %> from '<%= dasherizedModulePrefix %>/utils/<%= dasherizedModuleName %>'; +import { module, test } from 'qunit'; + +module('<%= friendlyTestName %>'); + +// Replace this with your real tests. +test('it works', function(assert) { + let result = <%= camelizedModuleName %>(); + assert.ok(result); +}); diff --git a/blueprints/util-test/index.js b/blueprints/util-test/index.js new file mode 100644 index 00000000000..6d1666a2e55 --- /dev/null +++ b/blueprints/util-test/index.js @@ -0,0 +1,14 @@ +/*jshint node:true*/ + +var testInfo = require('ember-cli-test-info'); +var stringUtils = require('ember-cli-string-utils'); + +module.exports = { + description: 'Generates a util unit test.', + locals: function(options) { + return { + friendlyTestName: testInfo.name(options.entity.name, 'Unit', 'Utility'), + dasherizedModulePrefix: stringUtils.dasherize(options.project.config().modulePrefix) + }; + } +}; diff --git a/blueprints/util/files/__root__/utils/__name__.js b/blueprints/util/files/__root__/utils/__name__.js new file mode 100644 index 00000000000..ab636c1792a --- /dev/null +++ b/blueprints/util/files/__root__/utils/__name__.js @@ -0,0 +1,3 @@ +export default function <%= camelizedModuleName %>() { + return true; +} diff --git a/blueprints/util/index.js b/blueprints/util/index.js new file mode 100644 index 00000000000..eec280cac03 --- /dev/null +++ b/blueprints/util/index.js @@ -0,0 +1,5 @@ +/*jshint node:true*/ + +module.exports = { + description: 'Generates a simple utility module/function.' +}; diff --git a/node-tests/blueprints/util-test.js b/node-tests/blueprints/util-test.js new file mode 100644 index 00000000000..38e37cc556e --- /dev/null +++ b/node-tests/blueprints/util-test.js @@ -0,0 +1,189 @@ +'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';" + ] + } + ] + }); + }); + +}); From 55a05aa64901c3011eb59cf9ee2f686a99cc7185 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Thu, 3 Mar 2016 19:30:26 +0100 Subject: [PATCH 09/21] blueprints: Import "service" blueprint from "ember-cli" --- .../files/tests/unit/__path__/__test__.js | 12 + blueprints/service-test/index.js | 12 + .../files/__root__/__path__/__name__.js | 4 + blueprints/service/index.js | 5 + node-tests/blueprints/service-test.js | 230 ++++++++++++++++++ 5 files changed, 263 insertions(+) create mode 100644 blueprints/service-test/files/tests/unit/__path__/__test__.js create mode 100644 blueprints/service-test/index.js create mode 100644 blueprints/service/files/__root__/__path__/__name__.js create mode 100644 blueprints/service/index.js create mode 100644 node-tests/blueprints/service-test.js diff --git a/blueprints/service-test/files/tests/unit/__path__/__test__.js b/blueprints/service-test/files/tests/unit/__path__/__test__.js new file mode 100644 index 00000000000..94db075869c --- /dev/null +++ b/blueprints/service-test/files/tests/unit/__path__/__test__.js @@ -0,0 +1,12 @@ +import { moduleFor, test } from 'ember-qunit'; + +moduleFor('service:<%= dasherizedModuleName %>', '<%= friendlyTestDescription %>', { + // Specify the other units that are required for this test. + // needs: ['service:foo'] +}); + +// Replace this with your real tests. +test('it exists', function(assert) { + let service = this.subject(); + assert.ok(service); +}); diff --git a/blueprints/service-test/index.js b/blueprints/service-test/index.js new file mode 100644 index 00000000000..89e718bad93 --- /dev/null +++ b/blueprints/service-test/index.js @@ -0,0 +1,12 @@ +/*jshint node:true*/ + +var testInfo = require('ember-cli-test-info'); + +module.exports = { + description: 'Generates a service unit test.', + locals: function(options) { + return { + friendlyTestDescription: testInfo.description(options.entity.name, 'Unit', 'Service') + }; + }, +}; diff --git a/blueprints/service/files/__root__/__path__/__name__.js b/blueprints/service/files/__root__/__path__/__name__.js new file mode 100644 index 00000000000..b9261c61d86 --- /dev/null +++ b/blueprints/service/files/__root__/__path__/__name__.js @@ -0,0 +1,4 @@ +import Ember from 'ember'; + +export default Ember.Service.extend({ +}); diff --git a/blueprints/service/index.js b/blueprints/service/index.js new file mode 100644 index 00000000000..66f5cbbd573 --- /dev/null +++ b/blueprints/service/index.js @@ -0,0 +1,5 @@ +/*jshint node:true*/ + +module.exports = { + description: 'Generates a service.' +}; diff --git a/node-tests/blueprints/service-test.js b/node-tests/blueprints/service-test.js new file mode 100644 index 00000000000..0dc3b9d3c1c --- /dev/null +++ b/node-tests/blueprints/service-test.js @@ -0,0 +1,230 @@ +'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 + } + ] + }); + }); + +}); From 7a134579de4d1b9f30bb0bbf4622685d5baa1fcb Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Thu, 3 Mar 2016 19:44:07 +0100 Subject: [PATCH 10/21] blueprints: Import "mixin" blueprint from "ember-cli" --- .../files/tests/unit/mixins/__name__-test.js | 12 + blueprints/mixin-test/index.js | 13 + .../mixin/files/__root__/mixins/__name__.js | 4 + blueprints/mixin/index.js | 5 + node-tests/blueprints/mixin-test.js | 317 ++++++++++++++++++ 5 files changed, 351 insertions(+) create mode 100644 blueprints/mixin-test/files/tests/unit/mixins/__name__-test.js create mode 100644 blueprints/mixin-test/index.js create mode 100644 blueprints/mixin/files/__root__/mixins/__name__.js create mode 100644 blueprints/mixin/index.js create mode 100644 node-tests/blueprints/mixin-test.js diff --git a/blueprints/mixin-test/files/tests/unit/mixins/__name__-test.js b/blueprints/mixin-test/files/tests/unit/mixins/__name__-test.js new file mode 100644 index 00000000000..72d60b1a9b3 --- /dev/null +++ b/blueprints/mixin-test/files/tests/unit/mixins/__name__-test.js @@ -0,0 +1,12 @@ +import Ember from 'ember'; +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) { + let <%= classifiedModuleName %>Object = Ember.Object.extend(<%= classifiedModuleName %>Mixin); + let subject = <%= classifiedModuleName %>Object.create(); + assert.ok(subject); +}); diff --git a/blueprints/mixin-test/index.js b/blueprints/mixin-test/index.js new file mode 100644 index 00000000000..a8080a88b45 --- /dev/null +++ b/blueprints/mixin-test/index.js @@ -0,0 +1,13 @@ +/*jshint node:true*/ + +var testInfo = require('ember-cli-test-info'); + +module.exports = { + 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/files/__root__/mixins/__name__.js b/blueprints/mixin/files/__root__/mixins/__name__.js new file mode 100644 index 00000000000..abf754d7160 --- /dev/null +++ b/blueprints/mixin/files/__root__/mixins/__name__.js @@ -0,0 +1,4 @@ +import Ember from 'ember'; + +export default Ember.Mixin.create({ +}); diff --git a/blueprints/mixin/index.js b/blueprints/mixin/index.js new file mode 100644 index 00000000000..891547dd1f1 --- /dev/null +++ b/blueprints/mixin/index.js @@ -0,0 +1,5 @@ +/*jshint node:true*/ + +module.exports = { + description: 'Generates a mixin.' +}; diff --git a/node-tests/blueprints/mixin-test.js b/node-tests/blueprints/mixin-test.js new file mode 100644 index 00000000000..15d8247b110 --- /dev/null +++ b/node-tests/blueprints/mixin-test.js @@ -0,0 +1,317 @@ +'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';" + ] + } + ] + }); + }); +}); From e9ffcd551b77afb0f6b41ac944273a8f4031c887 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Fri, 4 Mar 2016 13:37:39 +0100 Subject: [PATCH 11/21] blueprints: Import "helper" blueprints from "ember-cli" --- .../files/__root__/__path__/__name__.js | 1 + blueprints/helper-addon/index.js | 3 + .../files/tests/unit/helpers/__name__-test.js | 10 + blueprints/helper-test/index.js | 14 + .../helper/files/__root__/helpers/__name__.js | 7 + blueprints/helper/index.js | 10 + node-tests/blueprints/helper-addon-test.js | 24 ++ node-tests/blueprints/helper-test.js | 286 ++++++++++++++++++ 8 files changed, 355 insertions(+) create mode 100644 blueprints/helper-addon/files/__root__/__path__/__name__.js create mode 100644 blueprints/helper-addon/index.js create mode 100644 blueprints/helper-test/files/tests/unit/helpers/__name__-test.js create mode 100644 blueprints/helper-test/index.js create mode 100644 blueprints/helper/files/__root__/helpers/__name__.js create mode 100644 blueprints/helper/index.js create mode 100644 node-tests/blueprints/helper-addon-test.js create mode 100644 node-tests/blueprints/helper-test.js diff --git a/blueprints/helper-addon/files/__root__/__path__/__name__.js b/blueprints/helper-addon/files/__root__/__path__/__name__.js new file mode 100644 index 00000000000..a34b84552a1 --- /dev/null +++ b/blueprints/helper-addon/files/__root__/__path__/__name__.js @@ -0,0 +1 @@ +export { default, <%= camelizedModuleName %> } from '<%= modulePath %>'; diff --git a/blueprints/helper-addon/index.js b/blueprints/helper-addon/index.js new file mode 100644 index 00000000000..913fb8df2c5 --- /dev/null +++ b/blueprints/helper-addon/index.js @@ -0,0 +1,3 @@ +/*jshint node:true*/ + +module.exports = require('ember-cli/blueprints/addon-import'); diff --git a/blueprints/helper-test/files/tests/unit/helpers/__name__-test.js b/blueprints/helper-test/files/tests/unit/helpers/__name__-test.js new file mode 100644 index 00000000000..25a5954d155 --- /dev/null +++ b/blueprints/helper-test/files/tests/unit/helpers/__name__-test.js @@ -0,0 +1,10 @@ +import { <%= camelizedModuleName %> } from '<%= dasherizedModulePrefix %>/helpers/<%= dasherizedModuleName %>'; +import { module, test } from 'qunit'; + +module('<%= friendlyTestName %>'); + +// Replace this with your real tests. +test('it works', function(assert) { + let result = <%= camelizedModuleName %>([42]); + assert.ok(result); +}); diff --git a/blueprints/helper-test/index.js b/blueprints/helper-test/index.js new file mode 100644 index 00000000000..3ad1cd3b258 --- /dev/null +++ b/blueprints/helper-test/index.js @@ -0,0 +1,14 @@ +/*jshint node:true*/ + +var testInfo = require('ember-cli-test-info'); +var stringUtils = require('ember-cli-string-utils'); + +module.exports = { + description: 'Generates a helper unit test.', + locals: function(options) { + return { + friendlyTestName: testInfo.name(options.entity.name, 'Unit', 'Helper'), + dasherizedModulePrefix: stringUtils.dasherize(options.project.config().modulePrefix) + }; + } +}; diff --git a/blueprints/helper/files/__root__/helpers/__name__.js b/blueprints/helper/files/__root__/helpers/__name__.js new file mode 100644 index 00000000000..eb31fd5447d --- /dev/null +++ b/blueprints/helper/files/__root__/helpers/__name__.js @@ -0,0 +1,7 @@ +import Ember from 'ember'; + +export function <%= camelizedModuleName %>(params/*, hash*/) { + return params; +} + +export default Ember.Helper.helper(<%= camelizedModuleName %>); diff --git a/blueprints/helper/index.js b/blueprints/helper/index.js new file mode 100644 index 00000000000..ccf5b7c1807 --- /dev/null +++ b/blueprints/helper/index.js @@ -0,0 +1,10 @@ +'use strict'; +/*jshint node:true*/ +var normalizeEntityName = require('ember-cli-normalize-entity-name'); + +module.exports = { + description: 'Generates a helper function.', + normalizeEntityName: function(entityName) { + return normalizeEntityName(entityName); + } +}; diff --git a/node-tests/blueprints/helper-addon-test.js b/node-tests/blueprints/helper-addon-test.js new file mode 100644 index 00000000000..bf8a29e8d53 --- /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 00000000000..9703668280f --- /dev/null +++ b/node-tests/blueprints/helper-test.js @@ -0,0 +1,286 @@ +'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';" + } + ] + }); + }); + +}); From 0f0a5a59198a2aefeff5e125e3f33af9e4df39a5 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Fri, 4 Mar 2016 13:47:07 +0100 Subject: [PATCH 12/21] blueprints: Import "initializer" blueprints from "ember-cli" --- .../files/__root__/__path__/__name__.js | 1 + blueprints/initializer-addon/index.js | 3 + .../tests/unit/initializers/__name__-test.js | 22 ++ blueprints/initializer-test/index.js | 14 + .../files/__root__/initializers/__name__.js | 8 + blueprints/initializer/index.js | 5 + .../blueprints/initializer-addon-test.js | 24 ++ node-tests/blueprints/initializer-test.js | 331 ++++++++++++++++++ 8 files changed, 408 insertions(+) create mode 100644 blueprints/initializer-addon/files/__root__/__path__/__name__.js create mode 100644 blueprints/initializer-addon/index.js create mode 100644 blueprints/initializer-test/files/tests/unit/initializers/__name__-test.js create mode 100644 blueprints/initializer-test/index.js create mode 100644 blueprints/initializer/files/__root__/initializers/__name__.js create mode 100644 blueprints/initializer/index.js create mode 100644 node-tests/blueprints/initializer-addon-test.js create mode 100644 node-tests/blueprints/initializer-test.js diff --git a/blueprints/initializer-addon/files/__root__/__path__/__name__.js b/blueprints/initializer-addon/files/__root__/__path__/__name__.js new file mode 100644 index 00000000000..79e541af69d --- /dev/null +++ b/blueprints/initializer-addon/files/__root__/__path__/__name__.js @@ -0,0 +1 @@ +export { default, initialize } from '<%= modulePath %>'; diff --git a/blueprints/initializer-addon/index.js b/blueprints/initializer-addon/index.js new file mode 100644 index 00000000000..913fb8df2c5 --- /dev/null +++ b/blueprints/initializer-addon/index.js @@ -0,0 +1,3 @@ +/*jshint node:true*/ + +module.exports = require('ember-cli/blueprints/addon-import'); diff --git a/blueprints/initializer-test/files/tests/unit/initializers/__name__-test.js b/blueprints/initializer-test/files/tests/unit/initializers/__name__-test.js new file mode 100644 index 00000000000..b58aa2dbecc --- /dev/null +++ b/blueprints/initializer-test/files/tests/unit/initializers/__name__-test.js @@ -0,0 +1,22 @@ +import Ember from 'ember'; +import <%= classifiedModuleName %>Initializer from '<%= dasherizedModulePrefix %>/initializers/<%= dasherizedModuleName %>'; +import { module, test } from 'qunit'; + +let application; + +module('<%= friendlyTestName %>', { + beforeEach() { + Ember.run(function() { + application = Ember.Application.create(); + application.deferReadiness(); + }); + } +}); + +// Replace this with your real tests. +test('it works', function(assert) { + <%= classifiedModuleName %>Initializer.initialize(application); + + // you would normally confirm the results of the initializer here + assert.ok(true); +}); diff --git a/blueprints/initializer-test/index.js b/blueprints/initializer-test/index.js new file mode 100644 index 00000000000..4dd5180f7a0 --- /dev/null +++ b/blueprints/initializer-test/index.js @@ -0,0 +1,14 @@ +/*jshint node:true*/ + +var testInfo = require('ember-cli-test-info'); +var stringUtils = require('ember-cli-string-utils'); + +module.exports = { + description: 'Generates an initializer unit test.', + locals: function(options) { + return { + friendlyTestName: testInfo.name(options.entity.name, 'Unit', 'Initializer'), + dasherizedModulePrefix: stringUtils.dasherize(options.project.config().modulePrefix) + }; + } +}; diff --git a/blueprints/initializer/files/__root__/initializers/__name__.js b/blueprints/initializer/files/__root__/initializers/__name__.js new file mode 100644 index 00000000000..f47caae7cfa --- /dev/null +++ b/blueprints/initializer/files/__root__/initializers/__name__.js @@ -0,0 +1,8 @@ +export function initialize(/* application */) { + // application.inject('route', 'foo', 'service:foo'); +} + +export default { + name: '<%= dasherizedModuleName %>', + initialize +}; diff --git a/blueprints/initializer/index.js b/blueprints/initializer/index.js new file mode 100644 index 00000000000..48760763b48 --- /dev/null +++ b/blueprints/initializer/index.js @@ -0,0 +1,5 @@ +/*jshint node:true*/ + +module.exports = { + description: 'Generates an initializer.' +}; diff --git a/node-tests/blueprints/initializer-addon-test.js b/node-tests/blueprints/initializer-addon-test.js new file mode 100644 index 00000000000..b195b3cbb3c --- /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 00000000000..ccf2623d156 --- /dev/null +++ b/node-tests/blueprints/initializer-test.js @@ -0,0 +1,331 @@ +'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);" + ] + } + ] + }); + }); + +}); From 606e283aa96e6717cc4c7e297b586019af028cbb Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Fri, 4 Mar 2016 13:56:19 +0100 Subject: [PATCH 13/21] blueprints: Import "instance-initializer" blueprints from "ember-cli" --- .../files/__root__/__path__/__name__.js | 1 + .../instance-initializer-addon/index.js | 3 + .../instance-initializers/__name__-test.js | 25 ++ blueprints/instance-initializer-test/index.js | 14 + .../instance-initializers/__name__.js | 8 + blueprints/instance-initializer/index.js | 5 + .../instance-initializer-addon-test.js | 25 ++ .../blueprints/instance-initializer-test.js | 333 ++++++++++++++++++ 8 files changed, 414 insertions(+) create mode 100644 blueprints/instance-initializer-addon/files/__root__/__path__/__name__.js create mode 100644 blueprints/instance-initializer-addon/index.js create mode 100644 blueprints/instance-initializer-test/files/tests/unit/instance-initializers/__name__-test.js create mode 100644 blueprints/instance-initializer-test/index.js create mode 100644 blueprints/instance-initializer/files/__root__/instance-initializers/__name__.js create mode 100644 blueprints/instance-initializer/index.js create mode 100644 node-tests/blueprints/instance-initializer-addon-test.js create mode 100644 node-tests/blueprints/instance-initializer-test.js 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 00000000000..79e541af69d --- /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 00000000000..913fb8df2c5 --- /dev/null +++ b/blueprints/instance-initializer-addon/index.js @@ -0,0 +1,3 @@ +/*jshint node:true*/ + +module.exports = require('ember-cli/blueprints/addon-import'); diff --git a/blueprints/instance-initializer-test/files/tests/unit/instance-initializers/__name__-test.js b/blueprints/instance-initializer-test/files/tests/unit/instance-initializers/__name__-test.js new file mode 100644 index 00000000000..ec252a8fc4d --- /dev/null +++ b/blueprints/instance-initializer-test/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-test/index.js b/blueprints/instance-initializer-test/index.js new file mode 100644 index 00000000000..c08bc2d991b --- /dev/null +++ b/blueprints/instance-initializer-test/index.js @@ -0,0 +1,14 @@ +/*jshint node:true*/ + +var testInfo = require('ember-cli-test-info'); +var stringUtils = require('ember-cli-string-utils'); + +module.exports = { + 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/files/__root__/instance-initializers/__name__.js b/blueprints/instance-initializer/files/__root__/instance-initializers/__name__.js new file mode 100644 index 00000000000..4b96d1b34ca --- /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 00000000000..96afb7f58d8 --- /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/node-tests/blueprints/instance-initializer-addon-test.js b/node-tests/blueprints/instance-initializer-addon-test.js new file mode 100644 index 00000000000..6e159cbbc67 --- /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 00000000000..dbc9dbc3f78 --- /dev/null +++ b/node-tests/blueprints/instance-initializer-test.js @@ -0,0 +1,333 @@ +'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);" + ] + } + ] + }); + }); + +}); From d46e36c9959df8f8e2234ab4deb20a08983a8985 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Fri, 4 Mar 2016 14:54:39 +0100 Subject: [PATCH 14/21] blueprints: Import "route" blueprints from "ember-cli" --- .../files/tests/unit/__path__/__test__.js | 11 + blueprints/route-test/index.js | 12 + .../route/files/__root__/__path__/__name__.js | 4 + .../__templatepath__/__templatename__.hbs | 1 + blueprints/route/index.js | 122 ++++ node-tests/blueprints/route-test.js | 657 ++++++++++++++++++ 6 files changed, 807 insertions(+) create mode 100644 blueprints/route-test/files/tests/unit/__path__/__test__.js create mode 100644 blueprints/route-test/index.js create mode 100644 blueprints/route/files/__root__/__path__/__name__.js create mode 100644 blueprints/route/files/__root__/__templatepath__/__templatename__.hbs create mode 100644 blueprints/route/index.js create mode 100644 node-tests/blueprints/route-test.js diff --git a/blueprints/route-test/files/tests/unit/__path__/__test__.js b/blueprints/route-test/files/tests/unit/__path__/__test__.js new file mode 100644 index 00000000000..45dc2443468 --- /dev/null +++ b/blueprints/route-test/files/tests/unit/__path__/__test__.js @@ -0,0 +1,11 @@ +import { moduleFor, test } from 'ember-qunit'; + +moduleFor('route:<%= dasherizedModuleName %>', '<%= friendlyTestDescription %>', { + // Specify the other units that are required for this test. + // needs: ['controller:foo'] +}); + +test('it exists', function(assert) { + let route = this.subject(); + assert.ok(route); +}); diff --git a/blueprints/route-test/index.js b/blueprints/route-test/index.js new file mode 100644 index 00000000000..938a3abc3b5 --- /dev/null +++ b/blueprints/route-test/index.js @@ -0,0 +1,12 @@ +/*jshint node:true*/ + +var testInfo = require('ember-cli-test-info'); + +module.exports = { + description: 'Generates a route unit test.', + locals: function(options) { + return { + friendlyTestDescription: testInfo.description(options.entity.name, 'Unit', 'Route') + }; + }, +}; diff --git a/blueprints/route/files/__root__/__path__/__name__.js b/blueprints/route/files/__root__/__path__/__name__.js new file mode 100644 index 00000000000..26d9f3124ec --- /dev/null +++ b/blueprints/route/files/__root__/__path__/__name__.js @@ -0,0 +1,4 @@ +import Ember from 'ember'; + +export default Ember.Route.extend({ +}); diff --git a/blueprints/route/files/__root__/__templatepath__/__templatename__.hbs b/blueprints/route/files/__root__/__templatepath__/__templatename__.hbs new file mode 100644 index 00000000000..c24cd68950a --- /dev/null +++ b/blueprints/route/files/__root__/__templatepath__/__templatename__.hbs @@ -0,0 +1 @@ +{{outlet}} diff --git a/blueprints/route/index.js b/blueprints/route/index.js new file mode 100644 index 00000000000..d1b1f543820 --- /dev/null +++ b/blueprints/route/index.js @@ -0,0 +1,122 @@ +/*jshint node:true*/ + +var fs = require('fs-extra'); +var path = require('path'); +var chalk = require('chalk'); +var EmberRouterGenerator = require('ember-router-generator'); + +module.exports = { + description: 'Generates a route and a template, and registers the route with the router.', + + availableOptions: [ + { + name: 'path', + type: String, + default: '' + }, + { + name: 'skip-router', + type: Boolean, + default: false + }, + { + name: 'reset-namespace', + type: Boolean + } + ], + + fileMapTokens: function() { + return { + __templatepath__: function(options) { + if (options.pod) { + return path.join(options.podPath, options.dasherizedModuleName); + } + return 'templates'; + }, + __templatename__: function(options) { + if (options.pod) { + return 'template'; + } + return options.dasherizedModuleName; + }, + __root__: function(options) { + if (options.inRepoAddon) { + return path.join('lib', options.inRepoAddon, 'addon'); + } + + if (options.inDummy) { + return path.join('tests','dummy','app'); + } + + if (options.inAddon) { + return 'addon'; + } + + return 'app'; + } + }; + }, + + shouldEntityTouchRouter: function(name) { + var isIndex = name === 'index'; + var isBasic = name === 'basic'; + var isApplication = name === 'application'; + + return !isBasic && !isIndex && !isApplication; + }, + + shouldTouchRouter: function(name, options) { + var entityTouchesRouter = this.shouldEntityTouchRouter(name); + var isDummy = !!options.dummy; + var isAddon = !!options.project.isEmberCLIAddon(); + var isAddonDummyOrApp = (isDummy === isAddon); + + return (entityTouchesRouter && isAddonDummyOrApp && !options.dryRun && !options.inRepoAddon && !options.skipRouter); + }, + + afterInstall: function(options) { + updateRouter.call(this, 'add', options); + }, + + afterUninstall: function(options) { + updateRouter.call(this, 'remove', options); + } +}; + +function updateRouter(action, options) { + var entity = options.entity; + var actionColorMap = { + add: 'green', + remove: 'red' + }; + var color = actionColorMap[action] || 'gray'; + + if (this.shouldTouchRouter(entity.name, options)) { + writeRoute(action, entity.name, options); + + this.ui.writeLine('updating router'); + this._writeStatusToUI(chalk[color], action + ' route', entity.name); + } +} + +function findRouter(options) { + var routerPathParts = [options.project.root]; + + if (options.dummy && options.project.isEmberCLIAddon()) { + routerPathParts = routerPathParts.concat(['tests', 'dummy', 'app', 'router.js']); + } else { + routerPathParts = routerPathParts.concat(['app', 'router.js']); + } + + return routerPathParts; +} + +function writeRoute(action, name, options) { + var routerPath = path.join.apply(null, findRouter(options)); + var source = fs.readFileSync(routerPath, 'utf-8'); + + var routes = new EmberRouterGenerator(source); + var newRoutes = routes[action](name, options); + + fs.writeFileSync(routerPath, newRoutes.code()); +} diff --git a/node-tests/blueprints/route-test.js b/node-tests/blueprints/route-test.js new file mode 100644 index 00000000000..bb0a509be32 --- /dev/null +++ b/node-tests/blueprints/route-test.js @@ -0,0 +1,657 @@ +'use strict'; + +var fs = require('fs-extra'); +var path = require('path'); +var Promise = require('ember-cli/lib/ext/promise'); +var remove = Promise.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 + } + ] + }); + }); + +}); From 293167492a6169dbf7946c4a2e83594f374189f8 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Fri, 4 Mar 2016 17:33:49 +0100 Subject: [PATCH 15/21] blueprints: Import "route-addon" blueprints from "ember-cli" --- .../files/__root__/__path__/__name__.js | 1 + .../__templatepath__/__templatename__.js | 1 + blueprints/route-addon/index.js | 66 +++++++++++++++++++ node-tests/blueprints/route-addon-test.js | 30 +++++++++ 4 files changed, 98 insertions(+) create mode 100644 blueprints/route-addon/files/__root__/__path__/__name__.js create mode 100644 blueprints/route-addon/files/__root__/__templatepath__/__templatename__.js create mode 100644 blueprints/route-addon/index.js create mode 100644 node-tests/blueprints/route-addon-test.js diff --git a/blueprints/route-addon/files/__root__/__path__/__name__.js b/blueprints/route-addon/files/__root__/__path__/__name__.js new file mode 100644 index 00000000000..d921567455f --- /dev/null +++ b/blueprints/route-addon/files/__root__/__path__/__name__.js @@ -0,0 +1 @@ +export { default } from '<%= routeModulePath %>'; diff --git a/blueprints/route-addon/files/__root__/__templatepath__/__templatename__.js b/blueprints/route-addon/files/__root__/__templatepath__/__templatename__.js new file mode 100644 index 00000000000..2701b135456 --- /dev/null +++ b/blueprints/route-addon/files/__root__/__templatepath__/__templatename__.js @@ -0,0 +1 @@ +export { default } from '<%= templateModulePath %>'; diff --git a/blueprints/route-addon/index.js b/blueprints/route-addon/index.js new file mode 100644 index 00000000000..3c9020717b4 --- /dev/null +++ b/blueprints/route-addon/index.js @@ -0,0 +1,66 @@ +/*jshint node:true*/ + +var stringUtil = require('ember-cli-string-utils'); +var path = require('path'); +var inflector = require('inflection'); + +module.exports = { + description: 'Generates import wrappers for a route and its template.', + + fileMapTokens: function() { + return { + __templatepath__: function(options) { + if (options.pod) { + return path.join(options.podPath, options.dasherizedModuleName); + } + return 'templates'; + }, + __templatename__: function(options) { + if (options.pod) { + return 'template'; + } + return options.dasherizedModuleName; + }, + __name__: function (options) { + if (options.pod) { + return 'route'; + } + + return options.dasherizedModuleName; + }, + __path__: function(options) { + if (options.pod && options.hasPathToken) { + return path.join(options.podPath, options.dasherizedModuleName); + } + + return 'routes'; + }, + __root__: function(options) { + if (options.inRepoAddon) { + return path.join('lib', options.inRepoAddon, 'app'); + } + + return 'app'; + } + }; + }, + + locals: function (options) { + var locals = {}; + var addonRawName = options.inRepoAddon ? options.inRepoAddon : options.project.name(); + var addonName = stringUtil.dasherize(addonRawName); + var fileName = stringUtil.dasherize(options.entity.name); + + ['route', 'template'].forEach(function (blueprint) { + var pathName = [addonName, inflector.pluralize(blueprint), fileName].join('/'); + + if (options.pod) { + pathName = [addonName, fileName, blueprint].join('/'); + } + + locals[blueprint + 'ModulePath'] = pathName; + }); + + return locals; + } +}; diff --git a/node-tests/blueprints/route-addon-test.js b/node-tests/blueprints/route-addon-test.js new file mode 100644 index 00000000000..ae1307d4a7d --- /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';" + ] + }, + ] + }); + }); + +}); From c1122c6467a80fff47a7f7cb61f88c46ca5a7576 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Sat, 5 Mar 2016 08:24:01 +0100 Subject: [PATCH 16/21] blueprints: Import "addon-import" blueprint from "ember-cli" ... but not as a blueprint --- blueprints/-addon-import.js | 54 +++++++++++++++++++ blueprints/helper-addon/index.js | 2 +- blueprints/initializer-addon/index.js | 2 +- .../instance-initializer-addon/index.js | 2 +- 4 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 blueprints/-addon-import.js diff --git a/blueprints/-addon-import.js b/blueprints/-addon-import.js new file mode 100644 index 00000000000..3b83f2b8901 --- /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/helper-addon/index.js b/blueprints/helper-addon/index.js index 913fb8df2c5..270f28f7696 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/initializer-addon/index.js b/blueprints/initializer-addon/index.js index 913fb8df2c5..270f28f7696 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/instance-initializer-addon/index.js b/blueprints/instance-initializer-addon/index.js index 913fb8df2c5..270f28f7696 100644 --- a/blueprints/instance-initializer-addon/index.js +++ b/blueprints/instance-initializer-addon/index.js @@ -1,3 +1,3 @@ /*jshint node:true*/ -module.exports = require('ember-cli/blueprints/addon-import'); +module.exports = require('../-addon-import'); From 0645817978b72ffc1c499f8844d92963f71f6fff Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Sun, 6 Mar 2016 18:42:14 +0100 Subject: [PATCH 17/21] node-tests: Use RSVP.denodeify() instead of ember-cli internals --- node-tests/blueprints/route-test.js | 4 ++-- node-tests/nodetest-runner.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/node-tests/blueprints/route-test.js b/node-tests/blueprints/route-test.js index bb0a509be32..4f179f5dd0d 100644 --- a/node-tests/blueprints/route-test.js +++ b/node-tests/blueprints/route-test.js @@ -2,8 +2,8 @@ var fs = require('fs-extra'); var path = require('path'); -var Promise = require('ember-cli/lib/ext/promise'); -var remove = Promise.denodeify(fs.remove); +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'); diff --git a/node-tests/nodetest-runner.js b/node-tests/nodetest-runner.js index 05b1299f382..db5defd637b 100644 --- a/node-tests/nodetest-runner.js +++ b/node-tests/nodetest-runner.js @@ -2,7 +2,7 @@ var glob = require('glob'); var Mocha = require('mocha'); -var Promise = require('ember-cli/lib/ext/promise'); +var RSVP = require('rsvp'); var rimraf = require('rimraf'); var mochaOnlyDetector = require('mocha-only-detector'); @@ -14,7 +14,7 @@ rimraf.sync('.node_modules-tmp'); rimraf.sync('.bower_components-tmp'); var root = 'node-tests/{blueprints,acceptance,unit}'; -var _checkOnlyInTests = Promise.denodeify(mochaOnlyDetector.checkFolder.bind(null, root + '/**/*{-test}.js')); +var _checkOnlyInTests = RSVP.denodeify(mochaOnlyDetector.checkFolder.bind(null, root + '/**/*{-test}.js')); var optionOrFile = process.argv[2]; var mocha = new Mocha({ timeout: 5000, @@ -60,7 +60,7 @@ function ciVerificationStep() { if (process.env.CI === 'true') { return checkOnlyInTests(); } else { - return Promise.resolve(); + return RSVP.Promise.resolve(); } } From 68d449190f34f8c12cf3b2765341c574ba5bf0bc Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Mon, 14 Mar 2016 15:20:43 +0100 Subject: [PATCH 18/21] blueprints: Import "test-helper" blueprint from "ember-cli" --- .../files/tests/helpers/__name__.js | 5 ++++ blueprints/test-helper/index.js | 5 ++++ node-tests/blueprints/test-helper-test.js | 23 +++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 blueprints/test-helper/files/tests/helpers/__name__.js create mode 100644 blueprints/test-helper/index.js create mode 100644 node-tests/blueprints/test-helper-test.js diff --git a/blueprints/test-helper/files/tests/helpers/__name__.js b/blueprints/test-helper/files/tests/helpers/__name__.js new file mode 100644 index 00000000000..b5387d2d3f1 --- /dev/null +++ b/blueprints/test-helper/files/tests/helpers/__name__.js @@ -0,0 +1,5 @@ +import Ember from 'ember'; + +export default Ember.Test.registerAsyncHelper('<%= camelizedModuleName %>', function(app) { + +}); diff --git a/blueprints/test-helper/index.js b/blueprints/test-helper/index.js new file mode 100644 index 00000000000..54fc2633604 --- /dev/null +++ b/blueprints/test-helper/index.js @@ -0,0 +1,5 @@ +/*jshint node:true*/ + +module.exports = { + description: 'Generates a test helper.' +}; diff --git a/node-tests/blueprints/test-helper-test.js b/node-tests/blueprints/test-helper-test.js new file mode 100644 index 00000000000..83186422031 --- /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}' + ] + } + ] + }); + }); +}); From 37591ce8ea504170191d80094ab927e847ae8c3a Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Mon, 14 Mar 2016 15:25:47 +0100 Subject: [PATCH 19/21] blueprints: Add test framework detector This only supports QUnit for now --- blueprints/acceptance-test/index.js | 5 ++-- .../tests/acceptance/__name__-test.js | 0 blueprints/component-test/index.js | 5 ++-- .../tests/__testType__/__path__/__test__.js | 0 blueprints/controller-test/index.js | 5 ++-- .../tests/unit/__path__/__test__.js | 0 blueprints/helper-test/index.js | 5 ++-- .../tests/unit/helpers/__name__-test.js | 0 blueprints/initializer-test/index.js | 5 ++-- .../tests/unit/initializers/__name__-test.js | 0 blueprints/instance-initializer-test/index.js | 5 ++-- .../instance-initializers/__name__-test.js | 0 blueprints/mixin-test/index.js | 5 ++-- .../tests/unit/mixins/__name__-test.js | 0 blueprints/route-test/index.js | 5 ++-- .../tests/unit/__path__/__test__.js | 0 blueprints/service-test/index.js | 5 ++-- .../tests/unit/__path__/__test__.js | 0 blueprints/test-framework-detector.js | 23 +++++++++++++++++++ blueprints/util-test/index.js | 5 ++-- .../tests/unit/utils/__name__-test.js | 0 21 files changed, 53 insertions(+), 20 deletions(-) rename blueprints/acceptance-test/{files => qunit-files}/tests/acceptance/__name__-test.js (100%) rename blueprints/component-test/{files => qunit-files}/tests/__testType__/__path__/__test__.js (100%) rename blueprints/controller-test/{files => qunit-files}/tests/unit/__path__/__test__.js (100%) rename blueprints/helper-test/{files => qunit-files}/tests/unit/helpers/__name__-test.js (100%) rename blueprints/initializer-test/{files => qunit-files}/tests/unit/initializers/__name__-test.js (100%) rename blueprints/instance-initializer-test/{files => qunit-files}/tests/unit/instance-initializers/__name__-test.js (100%) rename blueprints/mixin-test/{files => qunit-files}/tests/unit/mixins/__name__-test.js (100%) rename blueprints/route-test/{files => qunit-files}/tests/unit/__path__/__test__.js (100%) rename blueprints/service-test/{files => qunit-files}/tests/unit/__path__/__test__.js (100%) create mode 100644 blueprints/test-framework-detector.js rename blueprints/util-test/{files => qunit-files}/tests/unit/utils/__name__-test.js (100%) diff --git a/blueprints/acceptance-test/index.js b/blueprints/acceptance-test/index.js index 38f85563c0b..16c481f3ff2 100644 --- a/blueprints/acceptance-test/index.js +++ b/blueprints/acceptance-test/index.js @@ -3,8 +3,9 @@ var testInfo = require('ember-cli-test-info'); var pathUtil = require('ember-cli-path-utils'); var stringUtils = require('ember-cli-string-utils'); +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()); @@ -17,4 +18,4 @@ module.exports = { friendlyTestName: testInfo.name(options.entity.name, 'Acceptance', null) }; } -}; +}); diff --git a/blueprints/acceptance-test/files/tests/acceptance/__name__-test.js b/blueprints/acceptance-test/qunit-files/tests/acceptance/__name__-test.js similarity index 100% rename from blueprints/acceptance-test/files/tests/acceptance/__name__-test.js rename to blueprints/acceptance-test/qunit-files/tests/acceptance/__name__-test.js diff --git a/blueprints/component-test/index.js b/blueprints/component-test/index.js index 2d4d80435fd..8a14227ac79 100644 --- a/blueprints/component-test/index.js +++ b/blueprints/component-test/index.js @@ -5,8 +5,9 @@ var testInfo = require('ember-cli-test-info'); var stringUtil = require('ember-cli-string-utils'); 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: [ @@ -64,4 +65,4 @@ module.exports = { ]); } } -}; +}); 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 100% rename from blueprints/component-test/files/tests/__testType__/__path__/__test__.js rename to blueprints/component-test/qunit-files/tests/__testType__/__path__/__test__.js diff --git a/blueprints/controller-test/index.js b/blueprints/controller-test/index.js index 1d11685752d..d13a07b42bd 100644 --- a/blueprints/controller-test/index.js +++ b/blueprints/controller-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 controller unit test.', locals: function(options) { return { friendlyTestDescription: testInfo.description(options.entity.name, 'Unit', 'Controller') }; } -}; +}); 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 100% rename from blueprints/controller-test/files/tests/unit/__path__/__test__.js rename to blueprints/controller-test/qunit-files/tests/unit/__path__/__test__.js diff --git a/blueprints/helper-test/index.js b/blueprints/helper-test/index.js index 3ad1cd3b258..5d3afcf1735 100644 --- a/blueprints/helper-test/index.js +++ b/blueprints/helper-test/index.js @@ -2,8 +2,9 @@ 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 { @@ -11,4 +12,4 @@ module.exports = { dasherizedModulePrefix: stringUtils.dasherize(options.project.config().modulePrefix) }; } -}; +}); 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 100% 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 diff --git a/blueprints/initializer-test/index.js b/blueprints/initializer-test/index.js index 4dd5180f7a0..dd48fc197e0 100644 --- a/blueprints/initializer-test/index.js +++ b/blueprints/initializer-test/index.js @@ -2,8 +2,9 @@ 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 { @@ -11,4 +12,4 @@ module.exports = { dasherizedModulePrefix: stringUtils.dasherize(options.project.config().modulePrefix) }; } -}; +}); 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 100% 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 diff --git a/blueprints/instance-initializer-test/index.js b/blueprints/instance-initializer-test/index.js index c08bc2d991b..f04393cbb9f 100644 --- a/blueprints/instance-initializer-test/index.js +++ b/blueprints/instance-initializer-test/index.js @@ -2,8 +2,9 @@ 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 instance initializer unit test.', locals: function(options) { return { @@ -11,4 +12,4 @@ module.exports = { dasherizedModulePrefix: stringUtils.dasherize(options.project.config().modulePrefix) }; } -}; +}); diff --git a/blueprints/instance-initializer-test/files/tests/unit/instance-initializers/__name__-test.js b/blueprints/instance-initializer-test/qunit-files/tests/unit/instance-initializers/__name__-test.js similarity index 100% rename from blueprints/instance-initializer-test/files/tests/unit/instance-initializers/__name__-test.js rename to blueprints/instance-initializer-test/qunit-files/tests/unit/instance-initializers/__name__-test.js diff --git a/blueprints/mixin-test/index.js b/blueprints/mixin-test/index.js index a8080a88b45..f0fb375f46d 100644 --- a/blueprints/mixin-test/index.js +++ b/blueprints/mixin-test/index.js @@ -1,8 +1,9 @@ /*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 { @@ -10,4 +11,4 @@ module.exports = { friendlyTestName: testInfo.name(options.entity.name, 'Unit', 'Mixin') }; } -}; +}); 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 100% 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 diff --git a/blueprints/route-test/index.js b/blueprints/route-test/index.js index 938a3abc3b5..ef4d986bfef 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') }; }, -}; +}); 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 100% rename from blueprints/route-test/files/tests/unit/__path__/__test__.js rename to blueprints/route-test/qunit-files/tests/unit/__path__/__test__.js diff --git a/blueprints/service-test/index.js b/blueprints/service-test/index.js index 89e718bad93..ca0a590e48f 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') }; }, -}; +}); 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 100% rename from blueprints/service-test/files/tests/unit/__path__/__test__.js rename to blueprints/service-test/qunit-files/tests/unit/__path__/__test__.js diff --git a/blueprints/test-framework-detector.js b/blueprints/test-framework-detector.js new file mode 100644 index 00000000000..ef5b4312cb7 --- /dev/null +++ b/blueprints/test-framework-detector.js @@ -0,0 +1,23 @@ +var path = require('path'); + +module.exports = function(blueprint) { + blueprint.supportsAddon = function() { + return false; + }; + + blueprint.filesPath = function() { + var type; + + var dependencies = this.project.dependencies(); + if ('ember-cli-qunit' in dependencies) { + type = 'qunit'; + } else { + this.ui.writeLine('Couldn\'t determine test style - using QUnit'); + type = 'qunit'; + } + + return path.join(this.path, type + '-files'); + }; + + return blueprint; +}; diff --git a/blueprints/util-test/index.js b/blueprints/util-test/index.js index 6d1666a2e55..99248d6cb62 100644 --- a/blueprints/util-test/index.js +++ b/blueprints/util-test/index.js @@ -2,8 +2,9 @@ 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 { @@ -11,4 +12,4 @@ module.exports = { dasherizedModulePrefix: stringUtils.dasherize(options.project.config().modulePrefix) }; } -}; +}); 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 100% 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 From d269929976a01b4898f08913750ea002f363929e Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Mon, 14 Mar 2016 16:10:42 +0100 Subject: [PATCH 20/21] blueprints: Import blueprints from "ember-cli-mocha" --- blueprints/acceptance-test/index.js | 10 ++++- .../tests/acceptance/__name__-test.js | 25 ++++++++++++ .../tests/__testType__/__path__/__test__.js | 34 ++++++++++++++++ .../tests/unit/__path__/__test__.js | 19 +++++++++ .../tests/unit/helpers/__name__-test.js | 12 ++++++ .../tests/unit/initializers/__name__-test.js | 24 +++++++++++ .../instance-initializers/__name__-test.js | 30 ++++++++++++++ .../tests/unit/mixins/__name__-test.js | 14 +++++++ .../tests/unit/__path__/__test__.js | 18 +++++++++ .../tests/unit/__path__/__name__-test.js | 19 +++++++++ blueprints/test-framework-detector.js | 2 + .../tests/unit/utils/__name__-test.js | 12 ++++++ node-tests/blueprints/acceptance-test-test.js | 23 +++++++++++ node-tests/blueprints/component-test.js | 40 +++++++++++++++++++ node-tests/blueprints/controller-test.js | 17 ++++++++ node-tests/blueprints/helper-test.js | 17 ++++++++ node-tests/blueprints/initializer-test.js | 19 +++++++++ .../blueprints/instance-initializer-test.js | 20 ++++++++++ node-tests/blueprints/mixin-test.js | 18 +++++++++ node-tests/blueprints/route-test.js | 17 ++++++++ node-tests/blueprints/service-test.js | 17 ++++++++ node-tests/blueprints/util-test.js | 17 ++++++++ 22 files changed, 423 insertions(+), 1 deletion(-) create mode 100644 blueprints/acceptance-test/mocha-files/tests/acceptance/__name__-test.js create mode 100644 blueprints/component-test/mocha-files/tests/__testType__/__path__/__test__.js create mode 100644 blueprints/controller-test/mocha-files/tests/unit/__path__/__test__.js create mode 100644 blueprints/helper-test/mocha-files/tests/unit/helpers/__name__-test.js create mode 100644 blueprints/initializer-test/mocha-files/tests/unit/initializers/__name__-test.js create mode 100644 blueprints/instance-initializer-test/mocha-files/tests/unit/instance-initializers/__name__-test.js create mode 100644 blueprints/mixin-test/mocha-files/tests/unit/mixins/__name__-test.js create mode 100644 blueprints/route-test/mocha-files/tests/unit/__path__/__test__.js create mode 100644 blueprints/service-test/mocha-files/tests/unit/__path__/__name__-test.js create mode 100644 blueprints/util-test/mocha-files/tests/unit/utils/__name__-test.js diff --git a/blueprints/acceptance-test/index.js b/blueprints/acceptance-test/index.js index 16c481f3ff2..2a358d53a7a 100644 --- a/blueprints/acceptance-test/index.js +++ b/blueprints/acceptance-test/index.js @@ -3,19 +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 = 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 00000000000..157583d2750 --- /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('Acceptance: <%= classifiedModuleName %>', 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(currentPath()).to.equal('<%= dasherizedModuleName %>'); + }); + }); +}); 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 00000000000..5c1fba75f9d --- /dev/null +++ b/blueprints/component-test/mocha-files/tests/__testType__/__path__/__test__.js @@ -0,0 +1,34 @@ +/* jshint expr:true */ +import { expect } from 'chai'; +import { describeComponent, it } from 'ember-mocha';<% if (testType === 'integration') { %> +import hbs from 'htmlbars-inline-precompile';<% } %> + +describeComponent( + '<%= dasherizedModuleName %>', + '<% if (testType === "integration") { %>Integration: <% } %><%= classifiedModuleName %>Component', + { + <% 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/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 00000000000..0040ef1ed3a --- /dev/null +++ b/blueprints/controller-test/mocha-files/tests/unit/__path__/__test__.js @@ -0,0 +1,19 @@ +/* jshint expr:true */ +import { expect } from 'chai'; +import { describeModule, it } from 'ember-mocha'; + +describeModule( + 'controller:<%= dasherizedModuleName %>', + '<%= classifiedModuleName %>Controller', + { + // 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/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 00000000000..8f55b328ab6 --- /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('<%= classifiedModuleName %>Helper', function() { + // Replace this with your real tests. + it('works', function() { + let result = <%= camelizedModuleName %>(42); + expect(result).to.be.ok; + }); +}); 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 00000000000..1388308f519 --- /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('<%= classifiedModuleName %>Initializer', 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/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 00000000000..abfc35020aa --- /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('<%= classifiedModuleName %>InstanceInitializer', 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/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 00000000000..02a86d74108 --- /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('<%= classifiedModuleName %>Mixin', 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/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 00000000000..0eca7c6a2ce --- /dev/null +++ b/blueprints/route-test/mocha-files/tests/unit/__path__/__test__.js @@ -0,0 +1,18 @@ +/* jshint expr:true */ +import { expect } from 'chai'; +import { describeModule, it } from 'ember-mocha'; + +describeModule( + 'route:<%= dasherizedModuleName %>', + '<%= classifiedModuleName %>Route', + { + // 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/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 00000000000..ef592c4d557 --- /dev/null +++ b/blueprints/service-test/mocha-files/tests/unit/__path__/__name__-test.js @@ -0,0 +1,19 @@ +/* jshint expr:true */ +import { expect } from 'chai'; +import { describeModule, it } from 'ember-mocha'; + +describeModule( + 'service:<%= dasherizedModuleName %>', + '<%= classifiedModuleName %>Service', + { + // 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/test-framework-detector.js b/blueprints/test-framework-detector.js index ef5b4312cb7..8f04dca3a60 100644 --- a/blueprints/test-framework-detector.js +++ b/blueprints/test-framework-detector.js @@ -11,6 +11,8 @@ module.exports = function(blueprint) { var dependencies = this.project.dependencies(); if ('ember-cli-qunit' in dependencies) { type = 'qunit'; + } else if ('ember-cli-mocha' in dependencies) { + type = 'mocha'; } else { this.ui.writeLine('Couldn\'t determine test style - using QUnit'); type = 'qunit'; 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 00000000000..4ae3eca1e54 --- /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('<%= camelizedModuleName %>', function() { + // Replace this with your real tests. + it('works', function() { + let result = <%= camelizedModuleName %>(); + expect(result).to.be.ok; + }); +}); diff --git a/node-tests/blueprints/acceptance-test-test.js b/node-tests/blueprints/acceptance-test-test.js index 78a35319499..9e920efe3a6 100644 --- a/node-tests/blueprints/acceptance-test-test.js +++ b/node-tests/blueprints/acceptance-test-test.js @@ -72,4 +72,27 @@ describe('Acceptance: ember generate and destroy acceptance-test', function() { }); }); + 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(currentPath()).to.equal('foo');" + ] + } + ] + }); + }); }); diff --git a/node-tests/blueprints/component-test.js b/node-tests/blueprints/component-test.js index 44ff5decbca..b267dd74ec2 100644 --- a/node-tests/blueprints/component-test.js +++ b/node-tests/blueprints/component-test.js @@ -1034,4 +1034,44 @@ describe('Acceptance: ember generate component', function() { }); }); + 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(\n '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(\n 'x-foo'", + "unit: true" + ] + } + ] + }); + }); }); diff --git a/node-tests/blueprints/controller-test.js b/node-tests/blueprints/controller-test.js index a00d7008351..4191fc08fd5 100644 --- a/node-tests/blueprints/controller-test.js +++ b/node-tests/blueprints/controller-test.js @@ -326,4 +326,21 @@ describe('Acceptance: ember generate and destroy controller', function() { }); }); + 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(\n 'controller:foo'" + ] + } + ] + }); + }); }); diff --git a/node-tests/blueprints/helper-test.js b/node-tests/blueprints/helper-test.js index 9703668280f..f098617e581 100644 --- a/node-tests/blueprints/helper-test.js +++ b/node-tests/blueprints/helper-test.js @@ -283,4 +283,21 @@ describe('Acceptance: ember generate and destroy helper', function() { }); }); + 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';" + ] + } + ] + }); + }); }); diff --git a/node-tests/blueprints/initializer-test.js b/node-tests/blueprints/initializer-test.js index ccf2623d156..0295ebb621e 100644 --- a/node-tests/blueprints/initializer-test.js +++ b/node-tests/blueprints/initializer-test.js @@ -328,4 +328,23 @@ describe('Acceptance: ember generate and destroy initializer', function() { }); }); + 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('FooInitializer', function() {", + "application = Ember.Application.create();", + "FooInitializer.initialize(application);" + ] + } + ] + }); + }); }); diff --git a/node-tests/blueprints/instance-initializer-test.js b/node-tests/blueprints/instance-initializer-test.js index dbc9dbc3f78..b5a28c405c2 100644 --- a/node-tests/blueprints/instance-initializer-test.js +++ b/node-tests/blueprints/instance-initializer-test.js @@ -330,4 +330,24 @@ describe('Acceptance: ember generate and destroy instance-initializer', function }); }); + 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('FooInstanceInitializer', 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 index 15d8247b110..732423b9e2a 100644 --- a/node-tests/blueprints/mixin-test.js +++ b/node-tests/blueprints/mixin-test.js @@ -314,4 +314,22 @@ describe('Acceptance: ember generate and destroy mixin', function() { ] }); }); + + 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';" + ] + } + ] + }); + }); }); diff --git a/node-tests/blueprints/route-test.js b/node-tests/blueprints/route-test.js index 4f179f5dd0d..680a0206064 100644 --- a/node-tests/blueprints/route-test.js +++ b/node-tests/blueprints/route-test.js @@ -654,4 +654,21 @@ describe('Acceptance: ember generate and destroy route', function() { }); }); + 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(\n 'route:foo'" + ] + } + ] + }); + }); }); diff --git a/node-tests/blueprints/service-test.js b/node-tests/blueprints/service-test.js index 0dc3b9d3c1c..481d684b8d7 100644 --- a/node-tests/blueprints/service-test.js +++ b/node-tests/blueprints/service-test.js @@ -227,4 +227,21 @@ describe('Acceptance: ember generate and destroy service', function() { }); }); + 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(\n 'service:foo'" + ] + } + ] + }); + }); }); diff --git a/node-tests/blueprints/util-test.js b/node-tests/blueprints/util-test.js index 38e37cc556e..6d3567dfb7f 100644 --- a/node-tests/blueprints/util-test.js +++ b/node-tests/blueprints/util-test.js @@ -186,4 +186,21 @@ describe('Acceptance: ember generate and destroy util', function() { }); }); + 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';" + ] + } + ] + }); + }); }); From a3a8996afdce21bdcb89f7c0a4725bc25c7178d0 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Mon, 14 Mar 2016 16:16:25 +0100 Subject: [PATCH 21/21] blueprints: Update mocha blueprints --- .../mocha-files/tests/acceptance/__name__-test.js | 4 ++-- .../mocha-files/tests/__testType__/__path__/__test__.js | 4 +--- .../mocha-files/tests/unit/__path__/__test__.js | 4 +--- .../mocha-files/tests/unit/helpers/__name__-test.js | 2 +- .../mocha-files/tests/unit/initializers/__name__-test.js | 2 +- .../tests/unit/instance-initializers/__name__-test.js | 2 +- .../mixin-test/mocha-files/tests/unit/mixins/__name__-test.js | 2 +- .../route-test/mocha-files/tests/unit/__path__/__test__.js | 4 +--- .../mocha-files/tests/unit/__path__/__name__-test.js | 4 +--- .../util-test/mocha-files/tests/unit/utils/__name__-test.js | 2 +- node-tests/blueprints/acceptance-test-test.js | 4 ++-- node-tests/blueprints/component-test.js | 4 ++-- node-tests/blueprints/controller-test.js | 2 +- node-tests/blueprints/helper-test.js | 3 ++- node-tests/blueprints/initializer-test.js | 2 +- node-tests/blueprints/instance-initializer-test.js | 2 +- node-tests/blueprints/mixin-test.js | 3 ++- node-tests/blueprints/route-test.js | 2 +- node-tests/blueprints/service-test.js | 2 +- node-tests/blueprints/util-test.js | 3 ++- 20 files changed, 26 insertions(+), 31 deletions(-) diff --git a/blueprints/acceptance-test/mocha-files/tests/acceptance/__name__-test.js b/blueprints/acceptance-test/mocha-files/tests/acceptance/__name__-test.js index 157583d2750..fb8e9ca2e68 100644 --- a/blueprints/acceptance-test/mocha-files/tests/acceptance/__name__-test.js +++ b/blueprints/acceptance-test/mocha-files/tests/acceptance/__name__-test.js @@ -4,7 +4,7 @@ import { expect } from 'chai'; import startApp from '../helpers/start-app'; <% if (destroyAppExists) { %>import destroyApp from '../helpers/destroy-app';<% } else { %>import Ember from 'ember';<% } %> -describe('Acceptance: <%= classifiedModuleName %>', function() { +describe('<%= friendlyTestName %>', function() { let application; beforeEach(function() { @@ -19,7 +19,7 @@ describe('Acceptance: <%= classifiedModuleName %>', function() { visit('/<%= dasherizedModuleName %>'); andThen(function() { - expect(currentPath()).to.equal('<%= dasherizedModuleName %>'); + expect(currentURL()).to.equal('/<%= dasherizedModuleName %>'); }); }); }); diff --git a/blueprints/component-test/mocha-files/tests/__testType__/__path__/__test__.js b/blueprints/component-test/mocha-files/tests/__testType__/__path__/__test__.js index 5c1fba75f9d..d09de151158 100644 --- a/blueprints/component-test/mocha-files/tests/__testType__/__path__/__test__.js +++ b/blueprints/component-test/mocha-files/tests/__testType__/__path__/__test__.js @@ -3,9 +3,7 @@ import { expect } from 'chai'; import { describeComponent, it } from 'ember-mocha';<% if (testType === 'integration') { %> import hbs from 'htmlbars-inline-precompile';<% } %> -describeComponent( - '<%= dasherizedModuleName %>', - '<% if (testType === "integration") { %>Integration: <% } %><%= classifiedModuleName %>Component', +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'], diff --git a/blueprints/controller-test/mocha-files/tests/unit/__path__/__test__.js b/blueprints/controller-test/mocha-files/tests/unit/__path__/__test__.js index 0040ef1ed3a..35039ace8af 100644 --- a/blueprints/controller-test/mocha-files/tests/unit/__path__/__test__.js +++ b/blueprints/controller-test/mocha-files/tests/unit/__path__/__test__.js @@ -2,9 +2,7 @@ import { expect } from 'chai'; import { describeModule, it } from 'ember-mocha'; -describeModule( - 'controller:<%= dasherizedModuleName %>', - '<%= classifiedModuleName %>Controller', +describeModule('controller:<%= dasherizedModuleName %>', '<%= friendlyTestDescription %>', { // Specify the other units that are required for this test. // needs: ['controller:foo'] 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 index 8f55b328ab6..85c42e7a561 100644 --- a/blueprints/helper-test/mocha-files/tests/unit/helpers/__name__-test.js +++ b/blueprints/helper-test/mocha-files/tests/unit/helpers/__name__-test.js @@ -3,7 +3,7 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; import { <%= camelizedModuleName %> } from '<%= dasherizedPackageName %>/helpers/<%= dasherizedModuleName %>'; -describe('<%= classifiedModuleName %>Helper', function() { +describe('<%= friendlyTestName %>', function() { // Replace this with your real tests. it('works', function() { let result = <%= camelizedModuleName %>(42); 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 index 1388308f519..f73838bb862 100644 --- a/blueprints/initializer-test/mocha-files/tests/unit/initializers/__name__-test.js +++ b/blueprints/initializer-test/mocha-files/tests/unit/initializers/__name__-test.js @@ -4,7 +4,7 @@ import { describe, it, beforeEach } from 'mocha'; import Ember from 'ember'; import <%= classifiedModuleName %>Initializer from '<%= dasherizedModulePrefix %>/initializers/<%= dasherizedModuleName %>'; -describe('<%= classifiedModuleName %>Initializer', function() { +describe('<%= friendlyTestName %>', function() { let application; beforeEach(function() { 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 index abfc35020aa..06d80f0a909 100644 --- 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 @@ -5,7 +5,7 @@ import Ember from 'ember'; import { initialize } from '<%= dasherizedModulePrefix %>/instance-initializers/<%= dasherizedModuleName %>'; import destroyApp from '../../helpers/destroy-app'; -describe('<%= classifiedModuleName %>InstanceInitializer', function() { +describe('<%= friendlyTestName %>', function() { let application, appInstance; beforeEach(function() { 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 index 02a86d74108..b59ffd058cf 100644 --- a/blueprints/mixin-test/mocha-files/tests/unit/mixins/__name__-test.js +++ b/blueprints/mixin-test/mocha-files/tests/unit/mixins/__name__-test.js @@ -4,7 +4,7 @@ import { describe, it } from 'mocha'; import Ember from 'ember'; import <%= classifiedModuleName %>Mixin from '<%= dasherizedPackageName %>/mixins/<%= dasherizedModuleName %>'; -describe('<%= classifiedModuleName %>Mixin', function() { +describe('<%= friendlyTestName %>', function() { // Replace this with your real tests. it('works', function() { let <%= classifiedModuleName %>Object = Ember.Object.extend(<%= classifiedModuleName %>Mixin); diff --git a/blueprints/route-test/mocha-files/tests/unit/__path__/__test__.js b/blueprints/route-test/mocha-files/tests/unit/__path__/__test__.js index 0eca7c6a2ce..54f8b9c4542 100644 --- a/blueprints/route-test/mocha-files/tests/unit/__path__/__test__.js +++ b/blueprints/route-test/mocha-files/tests/unit/__path__/__test__.js @@ -2,9 +2,7 @@ import { expect } from 'chai'; import { describeModule, it } from 'ember-mocha'; -describeModule( - 'route:<%= dasherizedModuleName %>', - '<%= classifiedModuleName %>Route', +describeModule('route:<%= dasherizedModuleName %>', '<%= friendlyTestDescription %>', { // Specify the other units that are required for this test. // needs: ['controller:foo'] 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 index ef592c4d557..ddc2d6afaa6 100644 --- a/blueprints/service-test/mocha-files/tests/unit/__path__/__name__-test.js +++ b/blueprints/service-test/mocha-files/tests/unit/__path__/__name__-test.js @@ -2,9 +2,7 @@ import { expect } from 'chai'; import { describeModule, it } from 'ember-mocha'; -describeModule( - 'service:<%= dasherizedModuleName %>', - '<%= classifiedModuleName %>Service', +describeModule('service:<%= dasherizedModuleName %>', '<%= friendlyTestDescription %>', { // Specify the other units that are required for this test. // needs: ['service:foo'] 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 index 4ae3eca1e54..558f0fa7dd5 100644 --- a/blueprints/util-test/mocha-files/tests/unit/utils/__name__-test.js +++ b/blueprints/util-test/mocha-files/tests/unit/utils/__name__-test.js @@ -3,7 +3,7 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; import <%= camelizedModuleName %> from '<%= dasherizedPackageName %>/utils/<%= dasherizedModuleName %>'; -describe('<%= camelizedModuleName %>', function() { +describe('<%= friendlyTestName %>', function() { // Replace this with your real tests. it('works', function() { let result = <%= camelizedModuleName %>(); diff --git a/node-tests/blueprints/acceptance-test-test.js b/node-tests/blueprints/acceptance-test-test.js index 9e920efe3a6..d2efd7a8300 100644 --- a/node-tests/blueprints/acceptance-test-test.js +++ b/node-tests/blueprints/acceptance-test-test.js @@ -85,11 +85,11 @@ describe('Acceptance: ember generate and destroy acceptance-test', function() { contains: [ "import { describe, it, beforeEach, afterEach } from 'mocha';", "import { expect } from 'chai';", - "describe('Acceptance: Foo', function() {", + "describe('Acceptance | foo', function() {", "it('can visit /foo', function() {", "visit('/foo');", "andThen(function() {", - "expect(currentPath()).to.equal('foo');" + "expect(currentURL()).to.equal('/foo');" ] } ] diff --git a/node-tests/blueprints/component-test.js b/node-tests/blueprints/component-test.js index b267dd74ec2..f2dd96e5723 100644 --- a/node-tests/blueprints/component-test.js +++ b/node-tests/blueprints/component-test.js @@ -1046,7 +1046,7 @@ describe('Acceptance: ember generate component', function() { contains: [ "import { describeComponent, it } from 'ember-mocha';", "import hbs from 'htmlbars-inline-precompile';", - "describeComponent(\n 'x-foo'", + "describeComponent('x-foo', 'Integration | Component | x foo'", "integration: true", "{{x-foo}}", "{{#x-foo}}" @@ -1067,7 +1067,7 @@ describe('Acceptance: ember generate component', function() { file: 'tests/unit/components/x-foo-test.js', contains: [ "import { describeComponent, it } from 'ember-mocha';", - "describeComponent(\n 'x-foo'", + "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 index 4191fc08fd5..66a84b6410a 100644 --- a/node-tests/blueprints/controller-test.js +++ b/node-tests/blueprints/controller-test.js @@ -337,7 +337,7 @@ describe('Acceptance: ember generate and destroy controller', function() { file: 'tests/unit/controllers/foo-test.js', contains: [ "import { describeModule, it } from 'ember-mocha';", - "describeModule(\n 'controller:foo'" + "describeModule('controller:foo', 'Unit | Controller | foo'" ] } ] diff --git a/node-tests/blueprints/helper-test.js b/node-tests/blueprints/helper-test.js index f098617e581..f63911355f4 100644 --- a/node-tests/blueprints/helper-test.js +++ b/node-tests/blueprints/helper-test.js @@ -294,7 +294,8 @@ describe('Acceptance: ember generate and destroy helper', function() { file: 'tests/unit/helpers/foo/bar-baz-test.js', contains: [ "import { describe, it } from 'mocha';", - "import { fooBarBaz } from 'my-app/helpers/foo/bar-baz';" + "import { fooBarBaz } from 'my-app/helpers/foo/bar-baz';", + "describe('Unit | Helper | foo/bar baz', function() {" ] } ] diff --git a/node-tests/blueprints/initializer-test.js b/node-tests/blueprints/initializer-test.js index 0295ebb621e..978484a72db 100644 --- a/node-tests/blueprints/initializer-test.js +++ b/node-tests/blueprints/initializer-test.js @@ -339,7 +339,7 @@ describe('Acceptance: ember generate and destroy initializer', function() { file: 'tests/unit/initializers/foo-test.js', contains: [ "import FooInitializer from 'my-app/initializers/foo';", - "describe('FooInitializer', function() {", + "describe('Unit | Initializer | foo', function() {", "application = Ember.Application.create();", "FooInitializer.initialize(application);" ] diff --git a/node-tests/blueprints/instance-initializer-test.js b/node-tests/blueprints/instance-initializer-test.js index b5a28c405c2..94e7e0b95c0 100644 --- a/node-tests/blueprints/instance-initializer-test.js +++ b/node-tests/blueprints/instance-initializer-test.js @@ -341,7 +341,7 @@ describe('Acceptance: ember generate and destroy instance-initializer', function file: 'tests/unit/instance-initializers/foo-test.js', contains: [ "import { initialize } from 'my-app/instance-initializers/foo';", - "describe('FooInstanceInitializer', function() {", + "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 index 732423b9e2a..37eb296d27d 100644 --- a/node-tests/blueprints/mixin-test.js +++ b/node-tests/blueprints/mixin-test.js @@ -326,7 +326,8 @@ describe('Acceptance: ember generate and destroy mixin', function() { file: 'tests/unit/mixins/foo-test.js', contains: [ "import { describe, it } from 'mocha';", - "import FooMixin from 'my-app/mixins/foo';" + "import FooMixin from 'my-app/mixins/foo';", + "describe('Unit | Mixin | foo', function() {" ] } ] diff --git a/node-tests/blueprints/route-test.js b/node-tests/blueprints/route-test.js index 680a0206064..918eb4b7b90 100644 --- a/node-tests/blueprints/route-test.js +++ b/node-tests/blueprints/route-test.js @@ -665,7 +665,7 @@ describe('Acceptance: ember generate and destroy route', function() { file: 'tests/unit/routes/foo-test.js', contains: [ "import { describeModule, it } from 'ember-mocha';", - "describeModule(\n 'route:foo'" + "describeModule('route:foo', 'Unit | Route | foo'" ] } ] diff --git a/node-tests/blueprints/service-test.js b/node-tests/blueprints/service-test.js index 481d684b8d7..d5fbe0de47e 100644 --- a/node-tests/blueprints/service-test.js +++ b/node-tests/blueprints/service-test.js @@ -238,7 +238,7 @@ describe('Acceptance: ember generate and destroy service', function() { file: 'tests/unit/services/foo-test.js', contains: [ "import { describeModule, it } from 'ember-mocha';", - "describeModule(\n 'service:foo'" + "describeModule('service:foo', 'Unit | Service | foo'" ] } ] diff --git a/node-tests/blueprints/util-test.js b/node-tests/blueprints/util-test.js index 6d3567dfb7f..422ee9e3798 100644 --- a/node-tests/blueprints/util-test.js +++ b/node-tests/blueprints/util-test.js @@ -197,7 +197,8 @@ describe('Acceptance: ember generate and destroy util', function() { file: 'tests/unit/utils/foo-bar-test.js', contains: [ "import { describe, it } from 'mocha';", - "import fooBar from 'my-app/utils/foo-bar';" + "import fooBar from 'my-app/utils/foo-bar';", + "describe('Unit | Utility | foo bar', function() {" ] } ]