I\'m trying to make some basic tests on REST requests I\'m doing using Angular $resource. The service code works just fine.
\'use strict\';
angular.module(
You were very close, the only thing missing was a call to the $httpBackend.flush();
. The working test looks like follows:
it('returns a JSON', inject(function(Device) {
var device = Device.get({ id: '50c61ff1d033a9b610000001' });
$httpBackend.flush();
expect(device.name).toEqual('Light');
}));
and a live test in plunker: http://plnkr.co/edit/Pp0LbLHs0Qxlgqkl948l?p=preview
You might also want to check docs for the $httpBackend mock.