-
Notifications
You must be signed in to change notification settings - Fork 14
improve component blueprint for octane #213
Changes from 3 commits
5c57a58
9d721f8
be2f7c1
3e86833
d152c31
76d8a32
02217a6
9f0269e
8670fdf
3c59cf8
76c8799
58d6499
dc4c154
ce84d15
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,36 @@ | ||
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(), '');<% } %> | ||
}); | ||
import hbs from 'htmlbars-inline-precompile';<% } %> | ||
import { TestContext } from 'ember-test-helpers'; | ||
|
||
type Context = TestContext & { | ||
// add your test properties here | ||
} | ||
|
||
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(this: Context, assert: 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.equal(this.$().text().trim(), ''); | ||
|
||
// Template block usage: | ||
this.render(hbs` | ||
<%= openComponent(componentName) %> | ||
template block text | ||
<%= closeComponent(componentName) %> | ||
`); | ||
|
||
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(), '');<% } %> | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,46 @@ | ||
<% if (testType === 'integration') { %>import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { TestContext } from 'ember-test-helpers'; | ||
import { render } from '@ember/test-helpers'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
<%= hbsImportStatement %> | ||
|
||
type Context = TestContext & { | ||
// add your test properties here | ||
} | ||
|
||
module('<%= friendlyTestDescription %>', function(hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
test('it renders', async function(assert) { | ||
test('it renders', async function(this: Context, assert: Assert) { | ||
// Set any properties with this.set('myProperty', 'value'); | ||
// Handle any actions with this.set('myAction', function(val) { ... }); | ||
|
||
await render(hbs`{{<%= componentPathName %>}}`); | ||
await render(hbs`<%= selfCloseComponent(componentName) %>`); | ||
|
||
assert.equal(this.element.textContent.trim(), ''); | ||
|
||
// Template block usage: | ||
await render(hbs` | ||
{{#<%= componentPathName %>}} | ||
<%= openComponent(componentName) %> | ||
template block text | ||
{{/<%= componentPathName %>}} | ||
<%= closeComponent(componentName) %> | ||
`); | ||
|
||
assert.equal(this.element.textContent.trim(), 'template block text'); | ||
}); | ||
});<% } else if (testType === 'unit') { %>import { module, test } from 'qunit'; | ||
import { setupTest } from 'ember-qunit'; | ||
import { TestContext } from 'ember-test-helpers'; | ||
|
||
type Context = TestContext & { | ||
// add your test properties here | ||
} | ||
|
||
module('<%= friendlyTestDescription %>', function(hooks) { | ||
setupTest(hooks); | ||
|
||
test('it exists', function(assert) { | ||
test('it exists', function(this: Context, assert: Assert) { | ||
let component = this.owner.factoryFor('component:<%= componentPathName %>').create(); | ||
assert.ok(component); | ||
}); | ||
});<% } %> | ||
});<% } %> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import Component from '@ember/component'; | ||
<%= importTemplate %> | ||
export default class <%= classifiedModuleName %> extends Component.extend({ | ||
// anything which *must* be merged to prototype here | ||
}) {<%= contents %> | ||
// normal class body definition here | ||
export default class <%= classifiedModuleName %> extends Component { | ||
// class body definition here | ||
BryanCrotaz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
import Component from '@glimmer/component'; | ||
|
||
interface <%= classifiedModuleName %>Args {} | ||
interface <%= classifiedModuleName %>Args { | ||
// define component arguments here | ||
} | ||
|
||
export default class <%= classifiedModuleName %> extends Component<<%= classifiedModuleName %>Args> {} | ||
export default class <%= classifiedModuleName %> extends Component<<%= classifiedModuleName %>Args> { | ||
BryanCrotaz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// class body definition here | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import Component from '@ember/component'; | ||
|
||
export default class <%= classifiedModuleName %> extends Component.extend({ | ||
// anything which *must* be merged to prototype here | ||
}) { | ||
// normal class body definition here | ||
export default class <%= classifiedModuleName %> extends Component { | ||
|
||
// class body definition here | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"compilerOptions":{"target":"es6","experimentalDecorators":true},"exclude":["node_modules","bower_components","tmp","vendor",".git","dist"]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thought: while we’re at it, we should, uhh, just get rid of the old-style
moduleFor*
blueprints. YIKES. I’d forgotten just how out of date our blueprints are. (Doesn’t have to be this PR.)