Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7a43512
Add blueprint dependencies
Turbo87 Mar 3, 2016
eab2871
Add "ember-cli-blueprint-test-helpers" dev dependency
Turbo87 Feb 22, 2016
5968d1d
blueprints: Import "template" blueprint from "ember-cli"
Turbo87 Feb 22, 2016
9722648
blueprints: Import "acceptance-test" blueprint from "ember-cli"
Turbo87 Mar 3, 2016
3332020
blueprints: Import "component" blueprint from "ember-cli"
Turbo87 Mar 3, 2016
5619d3c
blueprints: Import "component-addon" blueprint from "ember-cli"
Turbo87 Mar 3, 2016
b695cb0
blueprints: Import "controller" blueprint from "ember-cli"
Turbo87 Mar 3, 2016
5d64883
blueprints: Import "util" blueprint from "ember-cli"
Turbo87 Mar 3, 2016
55a05aa
blueprints: Import "service" blueprint from "ember-cli"
Turbo87 Mar 3, 2016
7a13457
blueprints: Import "mixin" blueprint from "ember-cli"
Turbo87 Mar 3, 2016
e9ffcd5
blueprints: Import "helper" blueprints from "ember-cli"
Turbo87 Mar 4, 2016
0f0a5a5
blueprints: Import "initializer" blueprints from "ember-cli"
Turbo87 Mar 4, 2016
606e283
blueprints: Import "instance-initializer" blueprints from "ember-cli"
Turbo87 Mar 4, 2016
d46e36c
blueprints: Import "route" blueprints from "ember-cli"
Turbo87 Mar 4, 2016
2931674
blueprints: Import "route-addon" blueprints from "ember-cli"
Turbo87 Mar 4, 2016
c1122c6
blueprints: Import "addon-import" blueprint from "ember-cli"
Turbo87 Mar 5, 2016
0645817
node-tests: Use RSVP.denodeify() instead of ember-cli internals
Turbo87 Mar 6, 2016
c615dee
Merge branch 'master' of github.com:emberjs/ember.js into blueprints
Turbo87 Mar 10, 2016
9b92761
Merge branch 'master' of github.com:emberjs/ember.js into blueprints
Turbo87 Mar 12, 2016
68d4491
blueprints: Import "test-helper" blueprint from "ember-cli"
Turbo87 Mar 14, 2016
37591ce
blueprints: Add test framework detector
Turbo87 Mar 14, 2016
d269929
blueprints: Import blueprints from "ember-cli-mocha"
Turbo87 Mar 14, 2016
a3a8996
blueprints: Update mocha blueprints
Turbo87 Mar 14, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node-tests/
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions bin/run-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
54 changes: 54 additions & 0 deletions blueprints/-addon-import.js
Original file line number Diff line number Diff line change
@@ -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
};
}
};
29 changes: 29 additions & 0 deletions blueprints/acceptance-test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*jshint node:true*/

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),
destroyAppExists: destroyAppExists
};
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* jshint expr:true */
import { describe, it, beforeEach, afterEach } from 'mocha';
import { expect } from 'chai';
import startApp from '../helpers/start-app';
<% if (destroyAppExists) { %>import destroyApp from '../helpers/destroy-app';<% } else { %>import Ember from 'ember';<% } %>

describe('<%= friendlyTestName %>', function() {
let application;

beforeEach(function() {
application = startApp();
});

afterEach(function() {
<% if (destroyAppExists) { %>destroyApp(application);<% } else { %>Ember.run(application, 'destroy');<% } %>
});

it('can visit /<%= dasherizedModuleName %>', function() {
visit('/<%= dasherizedModuleName %>');

andThen(function() {
expect(currentURL()).to.equal('/<%= dasherizedModuleName %>');
});
});
});
Original file line number Diff line number Diff line change
@@ -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 %>');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from '<%= modulePath %>';
56 changes: 56 additions & 0 deletions blueprints/component-addon/index.js
Original file line number Diff line number Diff line change
@@ -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)
};
}
};
68 changes: 68 additions & 0 deletions blueprints/component-test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*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');
var useTestFrameworkDetector = require('../test-framework-detector');

module.exports = useTestFrameworkDetector({
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' }
]);
}
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* jshint expr:true */
import { expect } from 'chai';
import { describeComponent, it } from 'ember-mocha';<% if (testType === 'integration') { %>
import hbs from 'htmlbars-inline-precompile';<% } %>

describeComponent('<%= componentPathName %>', '<%= friendlyTestDescription %>',
{
<% if (testType === 'integration' ) { %>integration: true<% } else if(testType === 'unit') { %>// Specify the other units that are required for this test
// needs: ['component:foo', 'helper:bar'],
unit: true<% } %>
},
function() {
it('renders', function() {
<% if (testType === 'integration' ) { %>// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.on('myAction', function(val) { ... });
// Template block usage:
// this.render(hbs`
// {{#<%= dasherizedModuleName %>}}
// template content
// {{/<%= dasherizedModuleName %>}}
// `);

this.render(hbs`{{<%= dasherizedModuleName %>}}`);
expect(this.$()).to.have.length(1);<% } else if(testType === 'unit') { %>// creates the component instance
let component = this.subject();
// renders the component on the page
this.render();
expect(component).to.be.ok;
expect(this.$()).to.have.length(1);<% } %>
});
}
);
Original file line number Diff line number Diff line change
@@ -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(), '');<% } %>
});
4 changes: 4 additions & 0 deletions blueprints/component/files/__root__/__path__/__name__.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Ember from 'ember';
<%= importTemplate %>
export default Ember.Component.extend({<%= contents %>
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{yield}}
Loading