-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19962 from cafreeman/cfreeman/typescript-blueprints
- Loading branch information
Showing
139 changed files
with
1,626 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
'use strict'; | ||
|
||
const stringUtil = require('ember-cli-string-utils'); | ||
const path = require('path'); | ||
const inflector = require('inflection'); | ||
|
||
module.exports = { | ||
description: 'Generates an import wrapper.', | ||
|
||
fileMapTokens: function () { | ||
return { | ||
__name__: function (options) { | ||
return options.dasherizedModuleName; | ||
}, | ||
__path__: function (options) { | ||
return inflector.pluralize(options.locals.blueprintName); | ||
}, | ||
__root__: function (options) { | ||
if (options.inRepoAddon) { | ||
return path.join('lib', options.inRepoAddon, 'app'); | ||
} | ||
return 'app'; | ||
}, | ||
}; | ||
}, | ||
|
||
locals: function (options) { | ||
let addonRawName = options.inRepoAddon ? options.inRepoAddon : options.project.name(); | ||
let addonName = stringUtil.dasherize(addonRawName); | ||
let fileName = stringUtil.dasherize(options.entity.name); | ||
let blueprintName = options.originBlueprintName; | ||
let modulePathSegments = [ | ||
addonName, | ||
inflector.pluralize(options.originBlueprintName), | ||
fileName, | ||
]; | ||
|
||
if (blueprintName.match(/-addon/)) { | ||
blueprintName = blueprintName.substr(0, blueprintName.indexOf('-addon')); | ||
modulePathSegments = [addonName, inflector.pluralize(blueprintName), fileName]; | ||
} | ||
|
||
return { | ||
modulePath: modulePathSegments.join('/'), | ||
blueprintName: blueprintName, | ||
}; | ||
}, | ||
}; |
24 changes: 24 additions & 0 deletions
24
blueprints-js/acceptance-test/mocha-files/tests/acceptance/__name__-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { describe, it, beforeEach, afterEach } from 'mocha'; | ||
import { expect } from 'chai'; | ||
import startApp from '<%= dasherizedPackageName %>/tests/helpers/start-app'; | ||
<% if (destroyAppExists) { %>import destroyApp from '<%= dasherizedPackageName %>/tests/helpers/destroy-app';<% } else { %>import { run } from '@ember/runloop';<% } %> | ||
|
||
describe('<%= friendlyTestName %>', function () { | ||
let application; | ||
|
||
beforeEach(function () { | ||
application = startApp(); | ||
}); | ||
|
||
afterEach(function () { | ||
<% if (destroyAppExists) { %>destroyApp(application);<% } else { %>run(application, 'destroy');<% } %> | ||
}); | ||
|
||
it('can visit /<%= dasherizedModuleName %>', function () { | ||
visit('/<%= dasherizedModuleName %>'); | ||
|
||
return andThen(() => { | ||
expect(currentURL()).to.equal('/<%= dasherizedModuleName %>'); | ||
}); | ||
}); | ||
}); |
File renamed without changes.
12 changes: 12 additions & 0 deletions
12
blueprints-js/acceptance-test/qunit-files/tests/acceptance/__name__-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.strictEqual(currentURL(), '/<%= dasherizedModuleName %>'); | ||
}); | ||
}); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
34 changes: 34 additions & 0 deletions
34
blueprints-js/component-test/mocha-0.12-files/__root__/__testType__/__path__/__test__.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { expect } from 'chai'; | ||
import { describe, it } from 'mocha'; | ||
import { setupComponentTest } from 'ember-mocha';<% if (testType === 'integration') { %> | ||
import hbs from 'htmlbars-inline-precompile';<% } %> | ||
|
||
describe('<%= friendlyTestDescription %>', function () { | ||
setupComponentTest('<%= componentPathName %>', { | ||
<% 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,<% } %> | ||
}); | ||
|
||
it('renders', function () { | ||
<% if (testType === 'integration' ) { %>// Set any properties with this.set('myProperty', 'value'); | ||
// Handle any actions with this.on('myAction', function(val) { ... }); | ||
|
||
this.render(hbs`<%= selfCloseComponent(componentName) %>`); | ||
expect(this.$()).to.have.length(1); | ||
|
||
// Template block usage: | ||
this.render(hbs` | ||
<%= openComponent(componentName) %> | ||
template block text | ||
<%= closeComponent(componentName) %> | ||
`); | ||
|
||
expect(this.$().text().trim()).to.equal('template block text');<% } 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);<% } %> | ||
}); | ||
}); |
36 changes: 36 additions & 0 deletions
36
blueprints-js/component-test/mocha-files/__root__/__testType__/__path__/__test__.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
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) { ... }); | ||
|
||
this.render(hbs`<%= selfCloseComponent(componentName) %>`); | ||
expect(this.$()).to.have.length(1); | ||
|
||
// Template block usage: | ||
this.render(hbs` | ||
<%= openComponent(componentName) %> | ||
template block text | ||
<%= closeComponent(componentName) %> | ||
`); | ||
|
||
expect(this.$().text().trim()).to.equal('template block text');<% } 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);<% } %> | ||
}); | ||
} | ||
); |
File renamed without changes.
31 changes: 31 additions & 0 deletions
31
blueprints-js/component-test/qunit-files/__root__/__testType__/__path__/__test__.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`<%= selfCloseComponent(componentName) %>`); | ||
|
||
assert.strictEqual(this.$().text().trim(), ''); | ||
|
||
// Template block usage: | ||
this.render(hbs` | ||
<%= openComponent(componentName) %> | ||
template block text | ||
<%= closeComponent(componentName) %> | ||
`); | ||
|
||
assert.strictEqual(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.strictEqual(this.$().text().trim(), '');<% } %> | ||
}); |
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions
1
blueprints-js/component/files/__root__/__templatepath__/__templatename__.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{yield}} |
16 changes: 16 additions & 0 deletions
16
blueprints-js/controller-test/mocha-0.12-files/__root__/__testType__/__path__/__test__.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { expect } from 'chai'; | ||
import { describe, it } from 'mocha'; | ||
import { setupTest } from 'ember-mocha'; | ||
|
||
describe('<%= friendlyTestDescription %>', function () { | ||
setupTest('controller:<%= dasherizedModuleName %>', { | ||
// Specify the other units that are required for this test. | ||
// needs: ['controller:foo'] | ||
}); | ||
|
||
// TODO: Replace this with your real tests. | ||
it('exists', function () { | ||
let controller = this.subject(); | ||
expect(controller).to.be.ok; | ||
}); | ||
}); |
18 changes: 18 additions & 0 deletions
18
blueprints-js/controller-test/mocha-files/__root__/__testType__/__path__/__test__.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { expect } from 'chai'; | ||
import { describeModule, it } from 'ember-mocha'; | ||
|
||
describeModule( | ||
'controller:<%= dasherizedModuleName %>', | ||
'<%= friendlyTestDescription %>', | ||
{ | ||
// Specify the other units that are required for this test. | ||
// needs: ['controller:foo'] | ||
}, | ||
function () { | ||
// TODO: Replace this with your real tests. | ||
it('exists', function () { | ||
let controller = this.subject(); | ||
expect(controller).to.be.ok; | ||
}); | ||
} | ||
); |
File renamed without changes.
12 changes: 12 additions & 0 deletions
12
blueprints-js/controller-test/qunit-files/__root__/__testType__/__path__/__test__.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'] | ||
}); | ||
|
||
// TODO: Replace this with your real tests. | ||
test('it exists', function (assert) { | ||
let controller = this.subject(); | ||
assert.ok(controller); | ||
}); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
26 changes: 26 additions & 0 deletions
26
...nts-js/helper-test/mocha-0.12-files/__root__/__testType__/__collection__/__name__-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { expect } from 'chai'; | ||
import { describe, it } from 'mocha'; | ||
import { setupComponentTest } from 'ember-mocha'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
describe('<%= friendlyTestName %>', function () { | ||
setupComponentTest('<%= dasherizedModuleName %>', { | ||
integration: true, | ||
}); | ||
|
||
it('renders', function () { | ||
// 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.set('inputValue', '1234'); | ||
|
||
this.render(hbs`{{<%= dasherizedModuleName %> this.inputValue}}`); | ||
|
||
expect(this.$().text().trim()).to.equal('1234'); | ||
}); | ||
}); |
28 changes: 28 additions & 0 deletions
28
blueprints-js/helper-test/mocha-files/__root__/__testType__/__collection__/__name__-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { expect } from 'chai'; | ||
import { describeComponent, it } from 'ember-mocha'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
describeComponent( | ||
'<%= dasherizedModuleName %>', | ||
'helper:<%= dasherizedModuleName %>', | ||
{ | ||
integration: true, | ||
}, | ||
function () { | ||
it('renders', function () { | ||
// 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.set('inputValue', '1234'); | ||
|
||
this.render(hbs`{{<%= dasherizedModuleName %> this.inputValue}}`); | ||
|
||
expect(this.$().text().trim()).to.equal('1234'); | ||
}); | ||
} | ||
); |
File renamed without changes.
15 changes: 15 additions & 0 deletions
15
blueprints-js/helper-test/qunit-files/__root__/__testType__/__collection__/__name__-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { moduleForComponent, test } from 'ember-qunit'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
moduleForComponent('<%= dasherizedModuleName %>', 'helper:<%= dasherizedModuleName %>', { | ||
integration: true, | ||
}); | ||
|
||
// TODO: Replace this with your real tests. | ||
test('it renders', function (assert) { | ||
this.set('inputValue', '1234'); | ||
|
||
this.render(hbs`{{<%= dasherizedModuleName %> this.inputValue}}`); | ||
|
||
assert.strictEqual(this.$().text().trim(), '1234'); | ||
}); |
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions
7
blueprints-js/helper/mu-files/__root__/__collection__/__name__.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { helper as buildHelper } from '@ember/component/helper'; | ||
|
||
export function <%= camelizedModuleName %>(positional /*, named*/) { | ||
return positional; | ||
} | ||
|
||
export const helper = buildHelper(<%= camelizedModuleName %>); |
File renamed without changes.
28 changes: 28 additions & 0 deletions
28
blueprints-js/initializer-test/mocha-files/__root__/__testType__/__path__/__name__-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { expect } from 'chai'; | ||
import { describe, it, beforeEach, afterEach } from 'mocha'; | ||
import { run } from '@ember/runloop'; | ||
import Application from '@ember/application'; | ||
import { initialize } from '<%= modulePrefix %>/initializers/<%= dasherizedModuleName %>'; | ||
<% if (destroyAppExists) { %>import destroyApp from '../../helpers/destroy-app';\n<% } %> | ||
describe('<%= friendlyTestName %>', function () { | ||
let application; | ||
|
||
beforeEach(function () { | ||
run(function () { | ||
application = Application.create(); | ||
application.deferReadiness(); | ||
}); | ||
}); | ||
|
||
afterEach(function () { | ||
<% if (destroyAppExists) { %>destroyApp(application);<% } else { %>run(application, 'destroy');<% } %> | ||
}); | ||
|
||
// TODO: Replace this with your real tests. | ||
it('works', function () { | ||
initialize(application); | ||
|
||
// you would normally confirm the results of the initializer here | ||
expect(true).to.be.ok; | ||
}); | ||
}); |
31 changes: 31 additions & 0 deletions
31
...s-js/initializer-test/mocha-rfc-232-files/__root__/__testType__/__path__/__name__-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { expect } from 'chai'; | ||
import { describe, it, beforeEach, afterEach } from 'mocha'; | ||
import Application from '@ember/application'; | ||
import { initialize } from '<%= modulePrefix %>/initializers/<%= dasherizedModuleName %>'; | ||
<% if (destroyAppExists) { %>import destroyApp from '../../helpers/destroy-app';<% } else { %>import { run } from '@ember/runloop';<% } %> | ||
|
||
describe('<%= friendlyTestName %>', function () { | ||
beforeEach(function () { | ||
this.TestApplication = Application.extend(); | ||
this.TestApplication.initializer({ | ||
name: 'initializer under test', | ||
initialize, | ||
}); | ||
|
||
this.application = this.TestApplication.create({ | ||
autoboot: false, | ||
}); | ||
}); | ||
|
||
afterEach(function () { | ||
<% if (destroyAppExists) { %>destroyApp(this.application);<% } else { %>run(this.application, 'destroy');<% } %> | ||
}); | ||
|
||
// TODO: Replace this with your real tests. | ||
it('works', async function () { | ||
await this.application.boot(); | ||
|
||
// you would normally confirm the results of the initializer here | ||
expect(true).to.be.ok; | ||
}); | ||
}); |
Oops, something went wrong.