XosConfirm tests

Change-Id: Ia7a8259d3905859d7eaeaa61fd09108238817ae9
diff --git a/src/app/core/confirm/confirm.service.spec.ts b/src/app/core/confirm/confirm.service.spec.ts
index 84a61de..d05899d 100644
--- a/src/app/core/confirm/confirm.service.spec.ts
+++ b/src/app/core/confirm/confirm.service.spec.ts
@@ -23,6 +23,8 @@
 let service: IXosConfirm;
 let modal;
 let modalInstance;
+let q;
+let scope;
 
 describe('The XosConfirm service', () => {
 
@@ -33,10 +35,14 @@
 
     angular.mock.inject((
       XosConfirm: IXosConfirm,
-      $uibModal: any
+      $uibModal: any,
+      $q: ng.IQService,
+      $rootScope: ng.IScope
     ) => {
       service = XosConfirm;
       modal = $uibModal;
+      q = $q;
+      scope = $rootScope;
     });
   });
 
@@ -54,19 +60,31 @@
         }]
       };
 
-    it('should open a modal', () => {
-      spyOn(modal, 'open');
+    it('should open the modal', () => {
+      spyOn(modal, 'open').and.returnValue('fake');
       modalInstance = service.open(test1);
       expect(modal.open).toHaveBeenCalled();
+      expect(modalInstance).toEqual('fake');
+      expect(service.modalInstance).toEqual('fake');
     });
-  });
 
-  // describe('the close method', () => {
-  //
-  // });
-  //
-  // describe('the dismiss method', () => {
-  //
-  // });
+    it('should close the modal', (done) => {
+      const p = q.defer();
+      const cb = jasmine.createSpy('cb').and.returnValue(p.promise);
+      service.modalInstance = {
+        close: jasmine.createSpy('close')
+      };
+
+      service.close(cb);
+      expect(cb).toHaveBeenCalled();
+      p.resolve();
+      scope.$apply();
+      expect(service.modalInstance.close).toHaveBeenCalled();
+      done();
+    });
+
+
+
+  });
 
 });