我正在尝试测试此功能(如下所列)。在我的测试文件中,我有:
var returnedId = cmCustomerDelegate.trimWorkStationId(workstationId);
但是returnedID
是undefined
。如何在不改变功能结构本身的情况下调用此函数?
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
};
}
]);