我有以下代碼:
angular.module('ps.workspaces').config(['$provide', function($provide) {
$provide.factory('workspacesNonCompliance', ['$filter', function($filter) {
return {
NonComplianceReasons: [
{name: $filter('translate')('NONCOMPLIANT.ALL'), noncompliant_properties: '' },
{name: $filter('translate')('NONCOMPLIANT.JAIL_BREAK_DETECTION'), noncompliant_properties: 'jail_break_detection' },
{name: $filter('translate')('NONCOMPLIANT.COMPLIANCE_ROOTED_DETECTION'), noncompliant_properties: 'compliance_rooted_detection' },
{name: $filter('translate')('NONCOMPLIANT.COMPLIANCE_USB_DEBUGGING'), noncompliant_properties: 'compliance_usb_debugging'},
{name: $filter('translate')('NONCOMPLIANT.POLICY_EXPIRED'), noncompliant_properties: 'policy_expired'}
]
};
}]);
}]);
我的模塊是:
angular.module('ps.workspaces', [
'ps.workspaces.workspacesDirective',
'ps.workspaces.workspacesFactories'
]);
我的測試是:
describe('Tests for workspacesNonCompliance /', function() {
var workspacesNonCompliance,
$provider,
$filter;
// beforeEach(module('ps.workspaces'));
// beforeEach(module('ps.workspaces.workspacesDirective'));
// beforeEach(module('ps.workspaces.workspacesFactories'));
beforeEach(function(){
angular.module('ps.workspaces', [
'ps.workspaces.workspacesDirective',
'ps.workspaces.workspacesFactories'
]);
});
describe('workspacesNonCompliance is array of noncompliance reasons /', function() {
beforeEach(function() {
inject(function ($injector) {
workspacesNonCompliance = $injector.get('workspacesNonCompliance');
$filter = $injector.get('$filter');
});
});
it('workspacesNonCompliance has array of noncompliance reasons', function() {
console.log('******* workspacesNonCompliance ', workspacesNonCompliance);
expect(workspacesNonCompliance.NonComplianceReasons).toContain({name: $filter('translate')('NONCOMPLIANT.ALL'), noncompliant_properties: '' });
});
});
});
試跑並得到錯誤信息:
錯誤:[$注射器:unpr]未知提供商:workspacesNonComplianceProvider < - workspacesNonCompliance http://errors.angularjs.org/1.3.18/ $注射器/ unpr P0 = workspacesNonComplianceProvider%20%3 C-%20workspacesNonCompliance 在/用戶/ joannepham/GIT中/ PWS /控制檯的UI/bower_components/angular/angular.js:63:12 at /Users/joannepham/git/pws/console-ui/bower_components/angular/angular.js:4031:19
找不到需要修復的內容這個案例。請幫忙