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

Commit4410f6b

Browse files
committed
Merge pull request#10 from rib3/definition-match-args
Match definitions by args
2 parents44e6b45 +45001d4 commit4410f6b

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

‎src/index.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ angular.module('js-data-mocks', ['js-data'])
739739
for(vari=0;i<definitions.length;i++){
740740
letdefinition=definitions[i];
741741

742-
if(definition.match(name,resourceName)){
742+
if(definition.match(name,resourceName)&&definition.matchArgs(args)){
743743
if(definition.response){
744744
responses.push(this.createResponse(resourceName,deferred,definition.response));
745745
returndeferred.promise;

‎test/test.js‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,34 @@ describe('test', function () {
5858
assert.equal(DS.find.callCount,4);
5959
});
6060
});
61+
62+
describe('definitions',function(){
63+
var$q;
64+
varDS;
65+
66+
beforeEach(inject(function(_$q_,_DS_){
67+
$q=_$q_;
68+
DS=_DS_;
69+
}));
70+
71+
it('should be matched by args',function(done){
72+
DS.when('findAll','post',{user:1})
73+
.respond([{id:1,user:1}]);
74+
75+
DS.when('findAll','post',{user:2})
76+
.respond([{id:2,user:2}]);
77+
78+
$q.all(
79+
DS.findAll('post',{user:1})
80+
.then(function(posts){
81+
assert.deepEqual(posts,[{id:1,user:1}]);
82+
}),
83+
DS.findAll('post',{user:2})
84+
.then(function(posts){
85+
assert.deepEqual(posts,[{id:2,user:2}]);
86+
})
87+
).finally(done);
88+
89+
DS.flush();
90+
});
91+
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp