Skip to content

Instantly share code, notes, and snippets.

@rwjblue
Created August 19, 2013 13:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rwjblue/6269405 to your computer and use it in GitHub Desktop.
Save rwjblue/6269405 to your computer and use it in GitHub Desktop.
Basic Ember.js test setup with QUnit (http://jsbin.com/oxasil/7/edit)
#ember-testing-container {
position: absolute;
background: white;
bottom: 0;
right: 0;
width: 640px;
height: 384px;
overflow: auto;
z-index: 9999;
border: 1px solid #ccc;
}
#ember-testing {
zoom: 50%;
}
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
<script src="http://code.jquery.com/jquery.js"></script>
<script src="http://builds.emberjs.com/handlebars-1.0.0.js"></script>
<script src="http://builds.emberjs.com/ember-1.0.0-rc.7.js"></script>
<script src="http://builds.emberjs.com/ember-data-latest.js"></script>
<script src="http://code.jquery.com/qunit/qunit-1.12.0.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.12.0.css" media="all">
</head>
<body>
<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">
{{outlet}}
</script>
<script type="text/x-handlebars" id="index">
<h1>People</h1>
<ul>
{{#each model}}
<li class="people">Hello, <b>{{fullName}}</b>!</li>
{{/each}}
</ul>
</script>
</body>
</html>
App = Ember.Application.create();
App.Store = DS.Store.extend({
adapter: DS.FixtureAdapter.create()
});
Ember.testing = true;
App.rootElement = '#ember-testing';
App.setupForTesting();
App.injectTestHelpers();
App.Batch = DS.Model.extend({
batchTypeId: DS.attr('number'),
batchType: DS.belongsTo('App.BatchType')
});
App.Batch.FIXTURES = [
{batchTypeId: 1 }
];
App.BatchType = DS.Model.extend({
name: DS.attr('string'),
batches: DS.hasMany('App.Batch')
});
App.BatchType.FIXTURES = [
{ name: 'Charges' }
];
App.IndexRoute = Ember.Route.extend({
model: function() { return App.Batch.find(); }
});
module("Model - Batch");
test('property: `batchType`', function(){
expect(3);
var property = App.Batch.metaForProperty('batchType');
equal(property.isRelationship, true,'Expected relationship');
equal(property.type, 'App.BatchType');
equal(property.kind, 'belongsTo');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment