Better error handling on resource arrays #334
Description
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