Skip to content

Commit

Permalink
Create shared qunit-fixture setup functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue committed Dec 22, 2017
1 parent 8ded2c0 commit 9bc6697
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
3 changes: 2 additions & 1 deletion packages/ember-application/tests/system/application_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ moduleFor('Ember.Application, default resolver with autoboot', class extends Def
}

[`@test Minimal Application initialized with just an application template`]() {
jQuery('#qunit-fixture').html('<script type="text/x-handlebars">Hello World</script>');
this.setupFixture('<script type="text/x-handlebars">Hello World</script>');

this.runTask(() => this.createApplication());
this.assertInnerHTML('Hello World');
}
Expand Down
8 changes: 3 additions & 5 deletions packages/ember-application/tests/system/bootstrap-test.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import { assign } from 'ember-utils';
import { jQuery } from 'ember-views';
import {
moduleFor,
DefaultResolverApplicationTestCase
} from 'internal-test-helpers';

moduleFor('Ember.Application with default resolver and autoboot', class extends DefaultResolverApplicationTestCase {
constructor() {
jQuery('#qunit-fixture').html(`
get fixture() {
return `
<div id="app"></div>
<script type="text/x-handlebars">Hello {{outlet}}</script>
<script type="text/x-handlebars" id="index">World!</script>
`);
super();
`;
}

get applicationOptions() {
Expand Down
10 changes: 10 additions & 0 deletions packages/internal-test-helpers/lib/test-cases/abstract.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ export default class AbstractTestCase {
this.element = null;
this.snapshot = null;
this.assert = QUnit.config.current.assert;

let { fixture } = this;
if (fixture) {
this.setupFixture(fixture);
}
}

teardown() {}
Expand All @@ -43,6 +48,11 @@ export default class AbstractTestCase {
return run.next(callback);
}

setupFixture(innerHTML) {
let fixture = document.querySelector('#qunit-fixture');
fixture.innerHTML = innerHTML;
}

// The following methods require `this.element` to work

get firstChild() {
Expand Down

0 comments on commit 9bc6697

Please sign in to comment.