I'm trying to test the submitForm() method that $scope.warehouse.$update but I got the following error.
Error
TypeError: 'null' is not an object (evaluating '$scope.warehouse.$update')
at /home/elopez/projects/tcs_economat/frontend/static_src/js/warehouses.js:63
at /home/elopez/projects/tcs_economat/frontend/static_src/test/unit/warehousesSpec.js:89
at i (/home/elopez/projects/tcs_economat/frontend/static/js/vendor.min.js:1)
at workFn (/home/elopez/projects/tcs_economat/frontend/static_src/bower_components/angular-mocks/angular-mocks.js:2436)
undefined
Method
$scope.submitForm = function () {
$scope.warehouse.$update(
form.onSuccess($scope, gettextCatalog.getString('Warehouse successfully updated!')),
form.onError($scope, gettextCatalog.getString("Error updating warehouse!"))
);
};
Test
it("should send request to update warehouse", inject(function (API) {
var warehouse = new API.Warehouse({});
//$httpBackend.expectPUT('/api/warehouses/4/').respond(204, {});
$scope.submitForm(warehouse);
$httpBackend.flush();
}));
Question
Should I mock the resource Warehouse ? If so how ?
Aucun commentaire:
Enregistrer un commentaire