ocombe / ocLazyLoad

Lazy load modules & components in AngularJS
https://oclazyload.readme.io
MIT License
2.63k stars 510 forks source link

Error when Instantiate module with ocLazyLoad in Jamine unit testing #351

Closed olaracuente closed 8 years ago

olaracuente commented 8 years ago

I have been working with jasmine unit testing like 2 months to test angularjs controllers and service. I found a issue when I try to instantiate another module of the app that have two array. I believe the issue is the oclazyload. Below you can see part of my module, the spec and the error. Please let me know what you you think I'm doing wrong. Ex. Part of my Module: angular.module('myTest.contract', [[ "Scripts/lib/angular-datepicker/angular-datepicker.min.js", "Scripts/lib/angular-datepicker/angular-datepicker.min.css", "Scripts/lib/angular-wizard/angular-wizard.min.css", "Scripts/lib/angular-wizard/angular-wizard.min.js", "Scripts/lib/angular-tree/css/tree-control-attribute.css", "Scripts/lib/angular-tree/angular-tree-control.js", "Contract/Requisition/js/services/TestDataService.js", "Contract/Requisition/js/services/TestsService.js" ], "ngAnimate", "ui.bootstrap", "ui.router", "angularUtils.directives.dirPagination", "toaster", "ncy-angular-breadcrumb", "datePicker", "uiSwitch", "ng-currency", "oc.lazyLoad", "mgo-angular-wizard", "treeControl" ]) .config([ '$stateProvider',function ($stateProvider) {

Spec describe('Unit Testing Module myTest.contract ', function () { 'use strict';

var $ocLazyLoad_,
  $rootScope = {},
    $controller;

   beforeEach(angular.mock.module('myTest.contract'));

   beforeEach(angular.mock.inject(function ($injector) {
        // Set up the mock responses
        $ocLazyLoad_ = $injector.get('$ocLazyLoad');    
        $rootScope = $injector.get('$rootScope');
        $controller = $injector.get('$controller');
      }));

      it('ocLazyLoad should be defined', function () {
        expect($ocLazyLoad_).toBeDefined();
    });

)};

Error: Error: [$injector:modulerr] Failed to instantiate module myTest.contract due to: Error: [$injector:modulerr] Failed to instantiate module Contract/Requisition/js/services/TestsService.js.js due to: Error: [ng:areq] Argument 'fn' is not a function, got string