Skip to content

Commit

Permalink
Merge pull request emberjs#12890 from Serabe/feature/improve-testing
Browse files Browse the repository at this point in the history
[WIP] [FEATURE beta] Use RenderingTest class and `moduleFor` for component invocation tests
  • Loading branch information
Godhuda committed Mar 19, 2016
2 parents a564a3f + b131c4a commit 51fdc08
Show file tree
Hide file tree
Showing 3 changed files with 731 additions and 774 deletions.
16 changes: 10 additions & 6 deletions packages/ember-glimmer/tests/utils/abstract-test-case.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,12 @@ export class TestCase {
return snapshot;
}

assertText(text) {
this.assert.strictEqual(this.textValue(), text, '#qunit-fixture content');
assertText(expected, message) {
this.assert.strictEqual(this.textValue(), expected, message || '#qunit-fixture content');
}

assertTextForSelector(selector, expected, message) {
this.assert.strictEqual(this.$(selector).text(), expected, message || `$(${selector}) content`);
}

assertHTML(html) {
Expand Down Expand Up @@ -252,10 +256,10 @@ export class RenderingTest extends TestCase {
return this.component;
}

render(templateStr, context = {}) {
render(templateStr, context = {}, { templateOptions = {} } = {}) {
let { renderer, owner } = this;

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

let attrs = assign({}, context, {
tagName: '',
Expand Down Expand Up @@ -289,15 +293,15 @@ export class RenderingTest extends TestCase {
}
}

registerComponent(name, { ComponentClass = null, template = null }) {
registerComponent(name, { ComponentClass = null, template = null, templateOptions = {} }) {
let { owner } = this;

if (ComponentClass) {
owner.register(`component:${name}`, ComponentClass);
}

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

Expand Down
Loading

0 comments on commit 51fdc08

Please sign in to comment.