Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 743bfcf

Browse files
test($resource): check we do not throw if response.data is the resource object
Closes #4508
1 parent 362d11b commit 743bfcf

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/ngResource/resourceSpec.js

+17
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,23 @@ describe("basic usage", function() {
152152
});
153153

154154

155+
it('should not throw if response.data is the resource object', function() {
156+
var data = {id:{key:123}, number:'9876'};
157+
$httpBackend.expect('GET', '/CreditCard/123').respond(data);
158+
159+
var cc = CreditCard.get({id:123});
160+
$httpBackend.flush();
161+
expect(cc instanceof CreditCard).toBe(true);
162+
163+
$httpBackend.expect('POST', '/CreditCard/123', angular.toJson(data)).respond(cc);
164+
165+
cc.$save();
166+
$httpBackend.flush();
167+
expect(cc.id).toEqual({key:123});
168+
expect(cc.number).toEqual('9876');
169+
});
170+
171+
155172
it('should default to empty parameters', function() {
156173
$httpBackend.expect('GET', 'URL').respond({});
157174
$resource('URL').query();

0 commit comments

Comments
 (0)