I'm trying to perform a very basic unit test on an Angular resource:
describe('coupons.resource', function () {
var Coupons, $httpBackend;
beforeEach(function () {
module('coupons.resource');
inject(function (_Coupons_, _$httpBackend_) {
Coupons = _Coupons_;
$httpBackend = _$httpBackend_;
});
});
it('should return empty array if it receives empty array', function () {
$httpBackend.expectGET(/admin\/coupons/).respond([]);
Coupons.query().$promise.then(function (data) {
console.log(data);
expect(data).toEqual([]);
});
$httpBackend.flush();
});
});
Coupons is a resource. The test above fails with the error:
Expected [] to equal []
The console output confirms that data expected is indeed an empty array. This seems so trivial. What am I doing wrong?