Skip to content

Commit

Permalink
Merge pull request #16896 from Dhaulagiri/br-232-helper
Browse files Browse the repository at this point in the history
add mocha rfc 232 test blueprints for helpers
  • Loading branch information
rwjblue committed Sep 5, 2018
2 parents 2c56af4 + e8b58ee commit 8d059ab
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 0 deletions.
@@ -0,0 +1,28 @@
import { expect } from 'chai';
<% if (testType == 'integration') { %>import { describe, it } from 'mocha';
import { setupRenderingTest } from 'ember-mocha';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

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

// Replace this with your real tests.
it('renders', async function() {
this.set('inputValue', '1234');

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

expect(this.element.textContent.trim()).to.equal('1234');
});
});<% } else if (testType == 'unit') { %>import { describe, it } from 'mocha';
import { <%= camelizedModuleName %> } from '<%= dasherizedPackageName %>/helpers/<%= dasherizedModuleName %>';

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

// Replace this with your real tests.
it('works', function() {
let result = <%= camelizedModuleName %>(42);
expect(result).to.be.ok;
});
});<% } %>
26 changes: 26 additions & 0 deletions node-tests/blueprints/helper-test-test.js
Expand Up @@ -109,6 +109,32 @@ describe('Blueprint: helper-test', function() {
});
});
});

describe('with ember-mocha@0.14.0', function() {
beforeEach(function() {
modifyPackages([
{ name: 'ember-cli-qunit', delete: true },
{ name: 'ember-mocha', dev: true },
]);
generateFakePackageManifest('ember-mocha', '0.14.0');
});

it('helper-test foo/bar-baz for mocha', function() {
return emberGenerateDestroy(['helper-test', 'foo/bar-baz'], _file => {
expect(_file('tests/integration/helpers/foo/bar-baz-test.js')).to.equal(
fixture('helper-test/mocha-rfc232.js')
);
});
});

it('helper-test foo/bar-baz for mocha --unit', function() {
return emberGenerateDestroy(['helper-test', 'foo/bar-baz', '--unit'], _file => {
expect(_file('tests/unit/helpers/foo/bar-baz-test.js')).to.equal(
fixture('helper-test/mocha-rfc232-unit.js')
);
});
});
});
});

describe('in addon', function() {
Expand Down
12 changes: 12 additions & 0 deletions node-tests/fixtures/helper-test/mocha-rfc232-unit.js
@@ -0,0 +1,12 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';
import { fooBarBaz } from 'my-app/helpers/foo/bar-baz';

describe('Unit | Helper | foo/bar-baz', function() {

// Replace this with your real tests.
it('works', function() {
let result = fooBarBaz(42);
expect(result).to.be.ok;
});
});
18 changes: 18 additions & 0 deletions node-tests/fixtures/helper-test/mocha-rfc232.js
@@ -0,0 +1,18 @@
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 | Helper | foo/bar-baz', function() {
setupRenderingTest();

// Replace this with your real tests.
it('renders', async function() {
this.set('inputValue', '1234');

await render(hbs`{{foo/bar-baz inputValue}}`);

expect(this.element.textContent.trim()).to.equal('1234');
});
});

0 comments on commit 8d059ab

Please sign in to comment.