Abstracting Component Creation in Ember Component Integration Tests
You can't use placeholders with the hbs
helper, see this issue. But, you can opt to use Ember.HTMLBars.compile
. Example:
function renderComponent(opts = {}) {
const {
title = 'Title',
subTitle = 'Subtitle',
blockContent = "{{#if (eq slot 'main')}}This is main content{{/if}}"
} = opts;
const content = Ember.HTMLBars.compile(`
{{#cloud-tools-layout title="${title}" subtitle="${subtitle}"}}
${blockContent}
{{/cloud-tools-layout}}
`);
this.render(content);
}
NOTE: You must include the ember-template-compiler
in your build file in order for this to work.
ember-cli-build.js:
if(app.env === 'test') {
app.import('bower_components/ember/ember-template-compiler.js');
}