-
-
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.
Add RFC 232 variant detector for mocha & component tests
- Loading branch information
1 parent
9ea80e1
commit b746968
Showing
5 changed files
with
137 additions
and
1 deletion.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
blueprints/component-test/mocha-rfc-232-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,38 @@ | ||
<% if (testType === 'integration') { %>import { expect } from 'chai'; | ||
import { describe, it } from 'mocha'; | ||
import { setupRenderingTest } from 'ember-mocha'; | ||
import { render } from '@ember/test-helpers'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
describe('<%= friendlyTestDescription %>', function() { | ||
setupRenderingTest(); | ||
|
||
it('renders', async function() { | ||
// Set any properties with this.set('myProperty', 'value'); | ||
// Handle any actions with this.set('myAction', function(val) { ... }); | ||
|
||
await render(hbs`{{<%= componentPathName %>}}`); | ||
|
||
expect(this.element.textContent.trim()).to.equal(''); | ||
|
||
// Template block usage: | ||
await render(hbs` | ||
{{#<%= componentPathName %>}} | ||
template block text | ||
{{/<%= componentPathName %>}} | ||
`); | ||
|
||
expect(this.element.textContent.trim()).to.equal('template block text'); | ||
}); | ||
});<% } else if (testType === 'unit') { %>import { expect } from 'chai'; | ||
import { describe, it } from 'mocha'; | ||
import { setupTest } from 'ember-mocha'; | ||
|
||
describe('<%= friendlyTestDescription %>', function() { | ||
setupTest(); | ||
|
||
it('exists', function() { | ||
let component = this.owner.factoryFor('component:<%= componentPathName %>').create(); | ||
expect(component).to.be.ok; | ||
}); | ||
});<% } %> |
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,12 @@ | ||
import { expect } from 'chai'; | ||
import { describe, it } from 'mocha'; | ||
import { setupTest } from 'ember-mocha'; | ||
|
||
describe('Unit | Component | x-foo', function() { | ||
setupTest(); | ||
|
||
it('exists', function() { | ||
let component = this.owner.factoryFor('component:x-foo').create(); | ||
expect(component).to.be.ok; | ||
}); | ||
}); |
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,27 @@ | ||
import { expect } from 'chai'; | ||
import { describe, it } from 'mocha'; | ||
import { setupRenderingTest } from 'ember-mocha'; | ||
import { render } from '@ember/test-helpers'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
describe('Integration | Component | x-foo', function() { | ||
setupRenderingTest(); | ||
|
||
it('renders', async function() { | ||
// Set any properties with this.set('myProperty', 'value'); | ||
// Handle any actions with this.set('myAction', function(val) { ... }); | ||
|
||
await render(hbs`{{x-foo}}`); | ||
|
||
expect(this.element.textContent.trim()).to.equal(''); | ||
|
||
// Template block usage: | ||
await render(hbs` | ||
{{#x-foo}} | ||
template block text | ||
{{/x-foo}} | ||
`); | ||
|
||
expect(this.element.textContent.trim()).to.equal('template block text'); | ||
}); | ||
}); |