1

我正在尝试测试该submitForm()方法,$scope.warehouse.$update但出现以下错误。

错误

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

方法

    $scope.submitForm = function () {
        $scope.warehouse.$update(
            form.onSuccess($scope, gettextCatalog.getString('Warehouse successfully updated!')),
            form.onError($scope, gettextCatalog.getString("Error updating warehouse!"))
        );
    };

测试

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();
}));

问题

我应该嘲笑资源Warehouse吗?如果有怎么办?

4

0 回答 0