I am new to writing jasmine test cases for angularJS factory.
I want to test the entire factory, but I'm unable to fetch getKeys
. Here's my factory.
My Factory is:
'use strict';
var a11yModule = angular.module('TestModule', ['ui.bootstrap']);
a11yModule.factory('TestFacotry', ['$q', '$timeout', function ($q, $timeout) {
return {
getKeys: function () {
return {
"abc": 32,
"gpa": 33,
"end": 35
};
}
};
}])
My Unit Spec is:
describe('modu testing', function () {
var TestFacotryMock, q, timeout;
beforeEach(module('TestModule', ['ui.bootstrap']));
beforeEach(inject(function (_$q_, _$timeout_, _TestFacotry_) {
q = _$q_;
timeout = _$timeout_;
TestFacotryMock = _TestFacotry_;
}));
it('Should ', function () {
//var output = TestFacotryMock.getKeys.something();
expect(typeof getKeys()).toBe('function');
});
});
Error is
Error: [$injector:modulerr] Failed to instantiate module TestModule due to: Error: [$injector:modulerr] Failed to instantiate module ui.bootstrap due to: Error: [$injector:nomod] Module 'ui.bootstrap' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.