Skip to content

Commit

Permalink
Updating node-test setup to use colocated component templates
Browse files Browse the repository at this point in the history
  • Loading branch information
ef4 committed Aug 21, 2024
1 parent 6bb1292 commit ec07664
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
24 changes: 12 additions & 12 deletions tests/node/app-boot-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ QUnit.module('App Boot', function (hooks) {
QUnit.test('nested {{component}}', function (assert) {
this.template('index', '{{root-component}}');

this.template(
'components/root-component',
this.component(
'root-component',
{
location: 'World',
hasExistence: true,
},
"\
<h1>Hello {{#if this.hasExistence}}{{this.location}}{{/if}}</h1>\
<div>{{component 'foo-bar'}}</div>\
"
<h1>Hello {{#if this.hasExistence}}{{this.location}}{{/if}}</h1>\
<div>{{component 'foo-bar'}}</div>\
"
);

this.component('root-component', {
location: 'World',
hasExistence: true,
});

this.template(
'components/foo-bar',
this.component(
'foo-bar',
undefined,
'\
<p>The files are *inside* the computer?!</p>\
'
Expand Down
9 changes: 7 additions & 2 deletions tests/node/helpers/setup-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ module.exports = function (hooks) {

this.Ember = Ember;
this.compile = compile;
this.setComponentTemplate = Ember._setComponentTemplate;
this.templateOnlyComponent = Ember._templateOnlyComponent;

Ember.testing = true;

Expand Down Expand Up @@ -166,8 +168,11 @@ function registerTemplate(name, template) {
this.register('template:' + name, this.compile(template));
}

function registerComponent(name, componentProps) {
let component = this.Ember.Component.extend(componentProps);
function registerComponent(name, componentProps, templateContents) {
let component = this.setComponentTemplate(
this.compile(templateContents),
componentProps ? this.Ember.Component.extend(componentProps) : this.templateOnlyComponent()
);
this.register('component:' + name, component);
}

Expand Down

0 comments on commit ec07664

Please sign in to comment.