Skip to content

Commit

Permalink
blueprints/component-test: Add RFC232 variants
Browse files Browse the repository at this point in the history
  • Loading branch information
Turbo87 committed Dec 6, 2017
1 parent 2cd4211 commit 16ab906
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<% if (testType === 'integration') { %>import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

module('<%= friendlyTestDescription %>', function(hooks) {
setupRenderingTest(hooks);

test('it renders', async function(assert) {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.set('myAction', function(val) { ... });

await render(hbs`{{<%= componentPathName %>}}`);

assert.equal(this.element.textContent.trim(), '');

// Template block usage:
await(hbs`
{{#<%= componentPathName %>}}
template block text
{{/<%= componentPathName %>}}
`);

assert.equal(this.element.textContent.trim(), 'template block text');
});
});<% } else if (testType === 'unit') { %>import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';

module('<%= friendlyTestDescription %>', function(hooks) {
setupTest(hooks);

test('it exists', function(assert) {
let component = this.owner.lookup('component:<%= componentPathName %>');
assert.ok(component);
});
});<% } %>
22 changes: 22 additions & 0 deletions node-tests/blueprints/component-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,28 @@ describe('Acceptance: ember generate component', function() {
}));
});

it('component-test x-foo for RFC232', function() {
var args = ['component-test', 'x-foo'];

return emberNew()
.then(() => generateFakePackageManifest('ember-cli-qunit', '4.1.1'))
.then(() => emberGenerateDestroy(args, _file => {
expect(_file('tests/integration/components/x-foo-test.js'))
.to.equal(fixture('component-test/rfc232.js'));
}));
});

it('component-test x-foo --unit for RFC232', function() {
var args = ['component-test', 'x-foo', '--unit'];

return emberNew()
.then(() => generateFakePackageManifest('ember-cli-qunit', '4.1.1'))
.then(() => emberGenerateDestroy(args, _file => {
expect(_file('tests/unit/components/x-foo-test.js'))
.to.equal(fixture('component-test/rfc232-unit.js'));
}));
});

it('component-test x-foo for mocha', function() {
var args = ['component-test', 'x-foo'];

Expand Down
11 changes: 11 additions & 0 deletions node-tests/fixtures/component-test/rfc232-unit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';

module('Unit | Component | x foo', function(hooks) {
setupTest(hooks);

test('it exists', function(assert) {
let component = this.owner.lookup('component:x-foo');
assert.ok(component);
});
});
26 changes: 26 additions & 0 deletions node-tests/fixtures/component-test/rfc232.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

module('Integration | Component | x foo', function(hooks) {
setupRenderingTest(hooks);

test('it renders', async function(assert) {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.set('myAction', function(val) { ... });

await render(hbs`{{x-foo}}`);

assert.equal(this.element.textContent.trim(), '');

// Template block usage:
await(hbs`
{{#x-foo}}
template block text
{{/x-foo}}
`);

assert.equal(this.element.textContent.trim(), 'template block text');
});
});

0 comments on commit 16ab906

Please sign in to comment.