如何测试Angular中未返回的函数?

时间:2017-02-09 14:56:58

标签: angularjs function

我正在尝试测试此功能(如下所列)。在我的测试文件中,我有:      var returnedId = cmCustomerDelegate.trimWorkStationId(workstationId); 但是returnedIDundefined。如何在不改变功能结构本身的情况下调用此函数?

angular.module('cmApp').factory('cmCustomerDelegate', [
    '$http',
    '$q',
    'GENERAL_CONFIG',
    '$rootScope',
    '$window',
    'logService',
    function ($http, $q, GENERAL_CONFIG, $rootScope, $window, logService) {
        var workStationId = $rootScope.decryptedValues.workStationId 

        //To trim the workstation Id off the starting element 'R' and last 4 elements '0101' - Example - RABCD1230101 becomes ABCD123
        function trimWorkStationId(workStationId){
            return workStationID
        }

        workStationId = trimWorkStationId(workStationId);

        return {
          //other functions are in here that can be called easily
        };
    }
]);

0 个答案:

没有答案