Skip to content

Commit

Permalink
Update embedded records tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
benkonrath committed Jul 23, 2015
1 parent 106942d commit a625340
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions tests/acceptance/embedded-records-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,33 +90,38 @@ module('Acceptance: Embedded Records', {
});

test('belongsTo retrieve', function(assert) {
assert.expect(2);
assert.expect(4);

return Ember.run(function() {

return store.findRecord('embedded-post-comment', 1).then(function(comment) {

assert.ok(comment);
assert.ok(comment.get('post'));

let post = comment.get('post');
assert.ok(post);
assert.equal(post.get('postTitle'), 'post title 1');
assert.equal(post.get('body'), 'post body 1');
});
});
});

test('hasMany retrieve', function(assert) {
assert.expect(6);
assert.expect(9);

return Ember.run(function() {

return store.findRecord('embedded-comments-post', 1).then(function(post) {

assert.ok(post);

let comments = post.get('comments');
assert.ok(comments);
assert.equal(comments.get('length'), 3);
assert.ok(comments.objectAt(0));
assert.equal(comments.objectAt(0).get('body'), 'comment body 1');
assert.ok(comments.objectAt(1));
assert.equal(comments.objectAt(1).get('body'), 'comment body 2');
assert.ok(comments.objectAt(2));
assert.equal(comments.objectAt(2).get('body'), 'comment body 3');
});
});
});
Expand All @@ -142,7 +147,6 @@ test('belongsTo create', function(assert) {

let requestBody = (JSON.parse(server.handledRequests.pop().requestBody));
assert.equal(requestBody.post, 2);

});
});
});
Expand Down
2 changes: 1 addition & 1 deletion tests/dummy/app/models/embedded-post-comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import DS from 'ember-data';

export default DS.Model.extend({
body: DS.attr(),
post: DS.belongsTo('post', {async: false})
post: DS.belongsTo('post', {async: true})
});

0 comments on commit a625340

Please sign in to comment.