define(['common/login/login.controller'], function() {
  describe('Login Module', function() {
    var scope, state, controller, AuthMock;

    beforeEach(module('ui.router'));
    beforeEach(module('app.common.login', function($provide) {
      AuthMock = jasmine.createSpyObj('AuthMock', ['isAuthed']);
      $provide.value('Auth', AuthMock);
    }));

    beforeEach(inject( function($rootScope, $controller, $state) {
      scope = $rootScope.$new();
      controller = $controller;
      state = $state;
    }));

    it('Should load the login state', function() {
      var stateName = 'login';

      controller('LoginCtrl', {$scope: scope, $state: state});
      expect(state.href(stateName, {})).toBe('#/login');
    });
  });
});

@@ -122,24 +122,58 @@
 roller, 
-AuthMock
+location, _AuthMock;%0A    var url = '/test'
 ;%0A%0A    b
@@ -243,99 +243,169 @@
 on.l
-ogin', function($provide) %7B%0A      AuthMock = jasmine.createSpyObj('AuthMock', %5B'isAuthed'%5D)
+ayout'));%0A    beforeEach(module('app.common.login', function($provide) %7B%0A      AuthMock = %7B%0A        isAuthed: function() %7B%7D,%0A        login: function() %7B%7D%0A      %7D
 ;%0A  
@@ -515,16 +515,27 @@
 , $state
+, $location
 ) %7B%0A    
@@ -617,16 +617,44 @@
 $state;%0A
+      location = $location;%0A
     %7D));
@@ -865,16 +865,1004 @@
 %0A    %7D);
+%0A%0A    it('Should redirect any url to login if not logged', function() %7B%0A      var stateName = 'login';%0A      spyOn(AuthMock,'isAuthed').andReturn(false);%0A      location.url(url);%0A      controller('LoginCtrl', %7B$scope: scope, $state: state%7D);%0A      state.go('main');%0A%0A      expect(AuthMock.isAuthed).toHaveBeenCalled();%0A      expect(state.is(%22login%22));%0A      expect(location.url()).toEqual('/login');%0A    %7D);%0A%0A    it('Should not redirect if logged', function() %7B%0A      spyOn(AuthMock,'isAuthed').andReturn(true);%0A      location.url(url);%0A      controller('LoginCtrl', %7B$scope: scope, $state: state%7D);%0A      state.go('main');%0A%0A      expect(AuthMock.isAuthed).toHaveBeenCalled();%0A      expect(state.is(%22main%22));%0A      expect(location.url()).toEqual(url);%0A    %7D);%0A%0A    it('Should call the Auth module', function() %7B%0A      spyOn(AuthMock,'login');%0A      controller('LoginCtrl', %7B$scope: scope, $state: state%7D);%0A%0A      scope.sendLogin();%0A      expect(AuthMock.login).toHaveBeenCalled();%0A    %7D);
 %0A  %7D);%0A%7D

Increase test coverage: Add unit tests to the login module part 2