Increase test coverage: Add unit test to the authentication module part 1 77/21877/1
authorMaxime Millette-Coulombe <mmcoulombe@inocybe.com>
Thu, 4 Jun 2015 15:14:11 +0000 (11:14 -0400)
committerMaxime Millette-Coulombe <mmcoulombe@inocybe.com>
Thu, 4 Jun 2015 15:14:24 +0000 (11:14 -0400)
I found that the angularjs cookies module was obtained somehow
be another module. This module is not used.

Change-Id: I853418f4d276de7ba7556f47ccf16f6409c322d7
Signed-off-by: Maxime Millette-Coulombe <mmcoulombe@inocybe.com>
modules/common-authentication-resources/src/main/resources/authentification/auth.services.js
modules/common-authentication-resources/src/main/resources/authentification/auth.spec.js [new file with mode: 0644]

index fa02910a6c4d9a2b917c833f0ecdb6c8a5cf2a28..14c2ecc4d436cf6a2642243bb7c6ef7880324a63 100644 (file)
@@ -8,7 +8,7 @@
 
 define(['common/authentification/auth.module'], function(auth) {
 
-  auth.factory('Auth', function($http, $window, $cookieStore, Base64, ENV){
+  auth.factory('Auth', function($http, $window, Base64, ENV){
           var factory = {};
           // Set Authorization header to username + password
           factory.setBasic = function(user, pw) {
diff --git a/modules/common-authentication-resources/src/main/resources/authentification/auth.spec.js b/modules/common-authentication-resources/src/main/resources/authentification/auth.spec.js
new file mode 100644 (file)
index 0000000..548fb90
--- /dev/null
@@ -0,0 +1,21 @@
+define(['common/authentification/auth.services'], function() {
+  describe('Auth Module', function() {
+    var _Auth;
+    beforeEach(module('app.common.auth'));
+
+    beforeEach(inject(function($injector) {
+      _Auth = $injector.get('Auth');
+    }));
+
+    it('Should have defined function facilate the authentication process', function() {
+      expect(_Auth.setBasic).toBeDefined();
+      expect(_Auth.unsetBasic).toBeDefined();
+      expect(_Auth.getUser).toBeDefined();
+      expect(_Auth.authorize).toBeDefined();
+      expect(_Auth.isAuthed).toBeDefined();
+      expect(_Auth.isLoggedIn).toBeDefined();
+      expect(_Auth.login).toBeDefined();
+      expect(_Auth.logout).toBeDefined();
+    });
+  });
+});