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

Better error handling on resource arrays #334

Closed
mhevery opened this issue Apr 29, 2011 · 0 comments
Closed

Better error handling on resource arrays #334

mhevery opened this issue Apr 29, 2011 · 0 comments

Comments

@mhevery
Copy link
Contributor

mhevery commented Apr 29, 2011

This should produce a better error!

I have problem with $resource and arrays. I have forked angular-seed
to test my problem in isolation:
https://github.com/witoldsz/resource-query-arrays


Controller:

function MyCtrl1($resource) {
var Item = $resource('items')
this.items = Item.query();
}
MyCtrl1.$inject = ['$resource'];


Scenario:

describe('MyCtrl1', function() {
var scope, browser, xhr, myCtrl1;

beforeEach(function(){
scope = angular.scope();
browser = scope.$service('$browser');
xhr = browser.xhr;
});

it('should ....', function() {
xhr.expectGET('items').respond(['item1','item2','item3']);
myCtrl1 = scope.$new(MyCtrl1);
xhr.flush();
expect(myCtrl1.items).toContain('item1');
});
});


Test result:

F.
Total 2 tests (Passed: 1; Fails: 1; Errors: 0) (5.00 ms)
Firefox 4.0 Linux: Run 2 tests (Passed: 1; Fails: 1; Errors 0) (5.00 ms)
MyCtrl1.should .... failed (5.00 ms): Error: Expected [ { 0 : 'i',
1 : 't', 2 : 'e', 3 : 'm', 4 : '1', $get : Function, $save : Function,
$query : Function, $remove : Function, $delete : Function }, { 0 :
'i', 1 : 't', 2 : 'e', 3 : 'm', 4 : '2', $get : Function, $save :
Function, $query : Function, $remove : Function, $delete : Function },
{ 0 : 'i', 1 : 't', 2 : 'e', 3 : 'm', 4 : '3', $get : Function, $save
: Function, $query : Function, $remove : Function, $delete : Function
} ] to contain 'item1'.
()@test/unit/controllersSpec.js:17

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant