我按照教程完成了这项工作:
Javascript:
App = Ember.Application.create();
App.Store = DS.Store.extend({
adapter: DS.FixtureAdapter
});
App.Router.map(function() {
this.route('edit', { path: ':person_id' });
});
App.IndexRoute = Ember.Route.extend({
model: function() {
return this.store.find('person');
}
});
App.Person = DS.Model.extend({
firstName: DS.attr('string'),
lastName: DS.attr('string')
});
App.Person.FIXTURES = [
{id: 1, firstName: 'Kris', lastName: 'Selden'},
{id: 2, firstName: 'Luke', lastName: 'Melia'},
{id: 3, firstName: 'Formerly Alex', lastName: 'Matchneer'}
];
App.rootElement = '#ember-testing';
App.setupForTesting();
App.injectTestHelpers();
function exists(selector) {
return !!find(selector).length;
}
module("Ember.js Library", {
setup: function() {
Ember.run(App, App.advanceReadiness);
},
teardown: function() {
App.reset();
}
});
test("Check HTML is returned", function() {
visit("/").then(function() {
ok(exists("*"), "Found HTML!");
});
});
模板:
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<div id="ember-testing-container"><div id="ember-testing"></div></div>
<script type="text/x-handlebars" data-template-name="application">
<h1>ember-latest jsfiddle</h1>
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="index">
<h2>Index Content:</h2>
<ul>
{{#each}}
<li>{{#link-to 'edit' this}} {{firstName}} {{lastName}} {{/link-to}}</li>
{{/each}}
</ul>
</script>
<script type="text/x-handlebars" data-template-name="edit">
<h2>Edit:</h2>
<p id='name'>
{{firstName}}
</p>
</script>
这是摆弄这个工作http://jsfiddle.net/marciojunior/GveWH/