Skip to content

Commit

Permalink
add mocha rfc 232 test blueprints for helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhaulagiri committed Aug 18, 2018
1 parent acd144f commit 7654c09
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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 7654c09

Please sign in to comment.