I have the following simple factory that i would like write a unit test around.
(function () {
"use strict";
angular
.module("math")
.factory("addservice", [addTwoNumbers]);
function addTwoNumbers(a, b) {
return a + b;
}
return { add: addTwoNumbers };
})();
This is what i have so far in my test spec.
describe('adding two numbers', function () {
var addService;
beforeEach(function () {
module('math');
inject(function ($injector) {
addService = $injector.get('addservice');
});
});
it('should add two numbers', function () {
var result = addService.addTwoNumbers(1, 1);
expect(result).toBe(2);
});
});
When trying to run this unit test i get TypeError: addService.addTwoNumbers is not a function. I am missing something obvious so any help is greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire