From e8b58eed1b58edd902ba5b6782cc18ccdb3b7c34 Mon Sep 17 00:00:00 2001 From: Brian Runnells Date: Sat, 18 Aug 2018 07:09:25 -0500 Subject: [PATCH] add mocha rfc 232 test blueprints for helpers --- .../__testType__/__path__/__name__-test.js | 28 +++++++++++++++++++ node-tests/blueprints/helper-test-test.js | 26 +++++++++++++++++ .../fixtures/helper-test/mocha-rfc232-unit.js | 12 ++++++++ .../fixtures/helper-test/mocha-rfc232.js | 18 ++++++++++++ 4 files changed, 84 insertions(+) create mode 100644 blueprints/helper-test/mocha-rfc-232-files/tests/__testType__/__path__/__name__-test.js create mode 100644 node-tests/fixtures/helper-test/mocha-rfc232-unit.js create mode 100644 node-tests/fixtures/helper-test/mocha-rfc232.js diff --git a/blueprints/helper-test/mocha-rfc-232-files/tests/__testType__/__path__/__name__-test.js b/blueprints/helper-test/mocha-rfc-232-files/tests/__testType__/__path__/__name__-test.js new file mode 100644 index 00000000000..caccbb8f1ce --- /dev/null +++ b/blueprints/helper-test/mocha-rfc-232-files/tests/__testType__/__path__/__name__-test.js @@ -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; + }); +});<% } %> diff --git a/node-tests/blueprints/helper-test-test.js b/node-tests/blueprints/helper-test-test.js index 16a6dc4e6df..b628a2333a5 100644 --- a/node-tests/blueprints/helper-test-test.js +++ b/node-tests/blueprints/helper-test-test.js @@ -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() { diff --git a/node-tests/fixtures/helper-test/mocha-rfc232-unit.js b/node-tests/fixtures/helper-test/mocha-rfc232-unit.js new file mode 100644 index 00000000000..d0a740ce037 --- /dev/null +++ b/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; + }); +}); diff --git a/node-tests/fixtures/helper-test/mocha-rfc232.js b/node-tests/fixtures/helper-test/mocha-rfc232.js new file mode 100644 index 00000000000..8f2a8d4338f --- /dev/null +++ b/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'); + }); +});