Я получаю следующую ошибку: TypeError: undefined is not a function
Проблема в том, что общим является модуль и фабрика, и проблема в моей линии.
var ctrl = $controllerConstructor("resetPasswordSentScreen", { $scope: scope, common: common});
Вот полный тест:
describe('resetPasswordSentScreen', function () {
var scope, $controllerConstructor;
beforeEach(module('common', 'app'));
beforeEach(inject(function($controller, $rootScope) {
scope = $rootScope.$new();
$controllerConstructor = $controller;
}));
it('it should navigate to the correct url when backToLogin is called ', function (common) {
var ctrl = $controllerConstructor("resetPasswordSentScreen", { $scope: scope, common: common });
var mocklocation = sinon.stub({ url: function () {}});
expect(scope.backToLogin()).toBe(mocklocation.url);
});
});