Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit61d140f

Browse files
committed
Added a test.#253
1 parent1e21413 commit61d140f

File tree

1 file changed

+57
-2
lines changed

1 file changed

+57
-2
lines changed

‎test/integration/datastore/sync_methods/inject.test.js‎

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ describe('DS.inject(resourceName, attrs[, options])', function () {
4646

4747
setTimeout(function(){
4848
assert.deepEqual('Doh! You just changed the primary key of an object! '+
49-
'I don\'t know how to handle this yet, so your data for the "post'+
50-
'" resource is now in an undefined (probably broken) state.',$log.error.logs[0][0]);
49+
'I don\'t know how to handle this yet, so your data for the "post'+
50+
'" resource is now in an undefined (probably broken) state.',$log.error.logs[0][0]);
5151

5252
done();
5353
},50);
@@ -276,4 +276,59 @@ describe('DS.inject(resourceName, attrs[, options])', function () {
276276
assert.isDefined(DS.get('foo',6));
277277
assert.isDefined(DS.get('foo',7));
278278
});
279+
it('should work when injecting child relations multiple times',function(){
280+
varParent=DS.defineResource({
281+
name:'parent',
282+
relations:{
283+
hasMany:{
284+
child:{
285+
localField:'children',
286+
foreignKey:'parentId'
287+
}
288+
}
289+
}
290+
});
291+
292+
varChild=DS.defineResource({
293+
name:'child',
294+
relations:{
295+
belongsTo:{
296+
parent:{
297+
localField:'parent',
298+
localKey:'parentId'
299+
}
300+
}
301+
}
302+
});
303+
304+
Parent.inject({
305+
id:1,
306+
name:'parent1',
307+
children:[{
308+
id:1,
309+
name:'child1'
310+
}]
311+
});
312+
313+
assert.isTrue(Parent.get(1).children[0]instanceofChild.Child);
314+
315+
Parent.inject({
316+
id:1,
317+
name:'parent',
318+
children:[
319+
{
320+
id:1,
321+
name:'Child-1'
322+
},
323+
{
324+
id:2,
325+
name:'Child-2'
326+
}
327+
]
328+
});
329+
330+
assert.isTrue(Parent.get(1).children[0]instanceofChild.Child);
331+
assert.isTrue(Parent.get(1).children[1]instanceofChild.Child);
332+
assert.deepEqual(Child.filter({parentId:1}),Parent.get(1).children);
333+
});
279334
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp