I have a directive whose controller
function has _.union
method being called.
$scope.arr = _.union($scope.$parent.arr,$scope.$parent.DDC.arr);
When i run my test cases, all the test-cases are failing because of the above line. If i comment out the above line, everything passes.
Below is my test-case:
describe("directive: Testing Modules", function() {
// Suite for testing an individual piece of our feature.
describe('Test Directive', function() {
var $compile, scope, elm,directive;
module('app');
beforeEach(module('templates'));
beforeEach(function() {
inject(function(_$rootScope_, _$compile_) {
$compile = _$compile_;
scope = _$rootScope_.$new();
});
inject(function($compile) {
elm = $compile('<directive></directive>')(scope);
scope.$digest();
directive = elm.scope();
});
});
describe('key date list Directive Initialization Test cases', function(){
it('directive should exist', function(){
expect(directive).toBeDefined();
})
it('arr variable should exist', function(){
expect(directive.arr).toBeDefined();
})
it('arr variable should be type of boolean', function(){
expect(directive.arr).toEqual(jasmine.any(Object));
})
})
});
});
In my karma.conf.js, i have included, above my app.js too.
'bower_components/ng-lodash/build/ng-lodash.min.js',