Skip to content

Commit

Permalink
[FEATURE beta] Use RenderingTest class and moduleFor for component …
Browse files Browse the repository at this point in the history
…invocation

This PR is a POC on using `RenderingTest` class and `moduleFor` in
component invocation tests.
  • Loading branch information
Serabe committed Mar 4, 2016
1 parent 8b643c6 commit 4242676
Show file tree
Hide file tree
Showing 3 changed files with 731 additions and 770 deletions.
12 changes: 10 additions & 2 deletions packages/ember-glimmer/tests/utils/abstract-test-case.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ export function applyMixins(TestClass, ...mixins) {
return TestClass;
}

function compileIfNeeded(template, options = {}) {
if (typeof template === 'string') {
return compile(template, options);
} else {
return template;
}
}

export function moduleFor(description, TestClass, ...mixins) {
let context;

Expand Down Expand Up @@ -156,7 +164,7 @@ export class RenderingTest extends TestCase {
render(templateStr, context = {}) {
let { renderer, owner } = this;

owner.register('template:-top-level', compile(templateStr));
owner.register('template:-top-level', compileIfNeeded(templateStr));

let attrs = assign({}, context, {
tagName: '',
Expand Down Expand Up @@ -198,7 +206,7 @@ export class RenderingTest extends TestCase {
}

if (typeof template === 'string') {
owner.register(`template:components/${name}`, compile(template, { env }));
owner.register(`template:components/${name}`, compileIfNeeded(template, { env }));
}
}

Expand Down
Loading

0 comments on commit 4242676

Please sign in to comment.