Skip to content

Commit 859e27c

Browse files
committed
Merge pull request #13571 from Gaurav0/helper_integration_tests
[BUGFIX] Update helper integration test blueprints
2 parents da9443e + 384b4cf commit 859e27c

File tree

5 files changed

+93
-22
lines changed

5 files changed

+93
-22
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/* jshint expr:true */
2+
import { expect } from 'chai';
3+
<% if (testType == 'integration') { %>
4+
import { describeComponent, it } from 'ember-mocha';
5+
import hbs from 'htmlbars-inline-precompile';
6+
7+
describeComponent('<%= dasherizedModuleName %>', 'helper:<%= dasherizedModuleName %>',
8+
{
9+
integration: true
10+
},
11+
function() {
12+
it('renders', function() {
13+
// Set any properties with this.set('myProperty', 'value');
14+
// Handle any actions with this.on('myAction', function(val) { ... });
15+
// Template block usage:
16+
// this.render(hbs`
17+
// {{#<%= dasherizedModuleName %>}}
18+
// template content
19+
// {{/<%= dasherizedModuleName %>}}
20+
// `);
21+
this.set('inputValue', '1234');
22+
23+
this.render(hbs`{{<%= dasherizedModuleName %> inputValue}}`);
24+
25+
expect(this.$().text().trim()).to.equal('1234');
26+
});
27+
}
28+
);
29+
<% } else if (testType == 'unit') { %>
30+
import { describe, it } from 'mocha';
31+
import { <%= camelizedModuleName %> } from '<%= dasherizedPackageName %>/helpers/<%= dasherizedModuleName %>';
32+
33+
describe('<%= friendlyTestName %>', function() {
34+
// Replace this with your real tests.
35+
it('works', function() {
36+
let result = <%= camelizedModuleName %>(42);
37+
expect(result).to.be.ok;
38+
});
39+
});
40+
<% } %>

blueprints/helper-test/mocha-files/tests/unit/helpers/__name__-test.js

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<% if (testType == 'integration') { %>
2+
import { moduleForComponent, test } from 'ember-qunit';
3+
import hbs from 'htmlbars-inline-precompile';
4+
5+
moduleForComponent('<%= dasherizedModuleName %>', 'helper:<%= dasherizedModuleName %>', {
6+
integration: true
7+
});
8+
9+
// Replace this with your real tests.
10+
test('it renders', function(assert) {
11+
this.set('inputValue', '1234');
12+
13+
this.render(hbs`{{<%= dasherizedModuleName %> inputValue}}`);
14+
15+
assert.equal(this.$().text().trim(), '1234');
16+
});
17+
<% } else if (testType == 'unit') { %>
18+
import { <%= camelizedModuleName %> } from '<%= dasherizedModulePrefix %>/helpers/<%= dasherizedModuleName %>';
19+
import { module, test } from 'qunit';
20+
21+
module('<%= friendlyTestName %>');
22+
23+
// Replace this with your real tests.
24+
test('it works', function(assert) {
25+
let result = <%= camelizedModuleName %>([42]);
26+
assert.ok(result);
27+
});
28+
<% } %>

blueprints/helper-test/qunit-files/tests/unit/helpers/__name__-test.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

node-tests/blueprints/helper-test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,16 @@ describe('Acceptance: ember generate and destroy helper', function() {
214214
}));
215215
});
216216

217+
it('helper-test foo/bar-baz --integration', function() {
218+
var args = ['helper-test', 'foo/bar-baz', '--integration'];
219+
220+
return emberNew()
221+
.then(() => emberGenerateDestroy(args, _file => {
222+
expect(_file('tests/integration/helpers/foo/bar-baz-test.js'))
223+
.to.contain("import hbs from 'htmlbars-inline-precompile';");
224+
}));
225+
});
226+
217227
it('helper-test foo/bar-baz', function() {
218228
var args = ['helper-test', 'foo/bar-baz'];
219229

@@ -234,6 +244,21 @@ describe('Acceptance: ember generate and destroy helper', function() {
234244
}));
235245
});
236246

247+
it('helper-test foo/bar-baz --integration for mocha', function() {
248+
var args = ['helper-test', 'foo/bar-baz', '--integration'];
249+
250+
return emberNew()
251+
.then(() => modifyPackages([
252+
{name: 'ember-cli-qunit', delete: true},
253+
{name: 'ember-cli-mocha', dev: true}
254+
]))
255+
.then(() => emberGenerateDestroy(args, _file => {
256+
expect(_file('tests/integration/helpers/foo/bar-baz-test.js'))
257+
.to.contain("import { describeComponent, it } from 'ember-mocha';")
258+
.to.contain("import hbs from 'htmlbars-inline-precompile';");
259+
}));
260+
});
261+
237262
it('helper-test foo/bar-baz for mocha', function() {
238263
var args = ['helper-test', 'foo/bar-baz'];
239264

0 commit comments

Comments
 (0)