Skip to content

Commit 520a20d

Browse files
ef4kategengler
authored andcommitted
Updating node-test setup to use colocated component templates
1 parent e1c3ab9 commit 520a20d

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

tests/node/app-boot-test.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@ QUnit.module('App Boot', function (hooks) {
1313
QUnit.test('nested {{component}}', function (assert) {
1414
this.template('index', '{{root-component}}');
1515

16-
this.template(
17-
'components/root-component',
16+
this.component(
17+
'root-component',
18+
{
19+
location: 'World',
20+
hasExistence: true,
21+
},
1822
"\
19-
<h1>Hello {{#if this.hasExistence}}{{this.location}}{{/if}}</h1>\
20-
<div>{{component 'foo-bar'}}</div>\
21-
"
23+
<h1>Hello {{#if this.hasExistence}}{{this.location}}{{/if}}</h1>\
24+
<div>{{component 'foo-bar'}}</div>\
25+
"
2226
);
2327

24-
this.component('root-component', {
25-
location: 'World',
26-
hasExistence: true,
27-
});
28-
29-
this.template(
30-
'components/foo-bar',
28+
this.component(
29+
'foo-bar',
30+
undefined,
3131
'\
3232
<p>The files are *inside* the computer?!</p>\
3333
'

tests/node/helpers/setup-app.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ module.exports = function (hooks) {
6161

6262
this.Ember = Ember;
6363
this.compile = compile;
64+
this.setComponentTemplate = Ember._setComponentTemplate;
65+
this.templateOnlyComponent = Ember._templateOnlyComponent;
6466

6567
Ember.testing = true;
6668

@@ -166,8 +168,11 @@ function registerTemplate(name, template) {
166168
this.register('template:' + name, this.compile(template));
167169
}
168170

169-
function registerComponent(name, componentProps) {
170-
let component = this.Ember.Component.extend(componentProps);
171+
function registerComponent(name, componentProps, templateContents) {
172+
let component = this.setComponentTemplate(
173+
this.compile(templateContents),
174+
componentProps ? this.Ember.Component.extend(componentProps) : this.templateOnlyComponent()
175+
);
171176
this.register('component:' + name, component);
172177
}
173178

0 commit comments

Comments
 (0)