Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e9a882e

Browse files
committedJan 18, 2016
Add parent test
1 parent e2f53c4 commit e9a882e

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
 

‎test/find.spec.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,33 @@ describe('DSHttpAdapter.find(resourceConfig, id, options)', function () {
124124
return otherAdapter.find(Post, 1);
125125
});
126126
});
127+
128+
it('should use parent', function () {
129+
var _this = this;
130+
131+
var Thing = datastore.defineResource({
132+
name: 'thing',
133+
endpoint: 'things',
134+
relations: {
135+
belongsTo: {
136+
user: {
137+
localKey: 'userId',
138+
localField: 'user',
139+
parent: true
140+
}
141+
}
142+
}
143+
});
144+
145+
setTimeout(function () {
146+
assert.equal(1, _this.requests.length);
147+
assert.equal(_this.requests[0].url, 'user/2/things/1');
148+
assert.equal(_this.requests[0].method, 'GET');
149+
_this.requests[0].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify({ id: 1 }));
150+
}, 30);
151+
152+
return dsHttpAdapter.find(Thing, 1, { params: { userId: 2 } }).then(function (data) {
153+
assert.deepEqual(data, { id: 1 }, 'thing should have been found');
154+
});
155+
});
127156
});

0 commit comments

Comments
 (0)
Please sign in to comment.