Skip to content

Commit

Permalink
Merge pull request #3686 from bmac/fix-broken-test
Browse files Browse the repository at this point in the history
Fix broken rest-serializer test.
  • Loading branch information
bmac committed Aug 21, 2015
2 parents abcbf0c + 4b58d1b commit 858dc5d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"devDependencies": {
"qunit": "~1.17.0",
"jquery": "~1.10.x",
"loader.js": "~3.3.0",
"loader.js": "~1.0.0",
"es5-shim": "~4.0.3"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,11 @@ test('normalizeResponse with async polymorphic hasMany', function() {
});
});


test("normalizeResponse can load secondary records of the same type without affecting the query count", function() {
env.registry.register('serializer:application', DS.RESTSerializer.extend({
isNewSerializerAPI: true
}));
var jsonHash = {
comments: [{ id: "1", body: "Parent Comment", root: true, children: [2, 3] }],
_comments: [
Expand All @@ -472,4 +476,40 @@ test("normalizeResponse can load secondary records of the same type without affe
run(function() {
array = env.restSerializer.normalizeResponse(env.store, Comment, jsonHash, '1', 'findRecord');
});

deepEqual(array, {
"data": {
"id": "1",
"type": "comment",
"attributes": {
"body": "Parent Comment",
"root": true
},
"relationships": {
"children": {
"data": [
{ "id": "2", "type": "comment" },
{ "id": "3", "type": "comment" }
]
}
}
},
"included": [{
"id": "2",
"type": "comment",
"attributes": {
"body": "Child Comment 1",
"root": false
},
"relationships": {}
}, {
"id": "3",
"type": "comment",
"attributes": {
"body": "Child Comment 2",
"root": false
},
"relationships": {}
}]
});
});

0 comments on commit 858dc5d

Please sign in to comment.