var mockMbaasServiceProxy = require('./stub/mbaas-service-proxy');
var mediator = require('fh-wfm-mediator/lib/mediator');
var express = require('express');
var proxyquire = require('proxyquire');
var sinon = require('sinon');
var assert = require('assert');

var sessionManager;

describe("User Sessions", function() {
  var verifySessionStub;

  beforeEach(function() {
    verifySessionStub = mockMbaasServiceProxy.getMockVerifySessionStub();
    sessionManager = proxyquire('./user-session', {
      './mbaas-service-proxy': mockMbaasServiceProxy.getMockSessionObject(verifySessionStub)
    });
    sessionManager(mediator, express(), 'my-service-name-guid');
  });

  it("Testing valid session token", function(done) {
    mediator.request('wfm:user:session:validate', 'myvalidsessiontoken').then(function(validationResponse) {
      sinon.assert.calledOnce(verifySessionStub);
      assert(validationResponse.isValid === true);
      done();
    }).catch(function(err) {
      assert.ok(!err, 'Error on myvalidsessiontoken' + err);
      done();
    });
  });

  it("Testing invalid session token", function(done) {
    mediator.request('wfm:user:session:validate', 'myinvalidsessiontoken').then(function(validationResponse) {
      sinon.assert.calledOnce(verifySessionStub);
      assert(validationResponse.isValid === false);
      done();
    })
      .catch(function(err) {
        assert.ok(!err, 'Error on myinvalidsessiontoken' + err);
        done();
      });
  });
});
@@ -705,36 +705,32 @@
 %22, function(
-done
 ) %7B%0A    
 mediator.req
@@ -709,32 +709,39 @@
 unction() %7B%0A    
+return 
 mediator.request
@@ -934,126 +934,8 @@
 e);%0A
-      done();%0A    %7D).catch(function(err) %7B%0A      assert.ok(!err, 'Error on myvalidsessiontoken' + err);%0A      done();%0A
     
@@ -996,20 +996,16 @@
 ion(
-done
 ) %7B%0A    
 medi
@@ -1000,16 +1000,23 @@
 ) %7B%0A    
+return 
 mediator
@@ -1220,141 +1220,8 @@
 e);%0A
-      done();%0A    %7D)%0A      .catch(function(err) %7B%0A        assert.ok(!err, 'Error on myinvalidsessiontoken' + err);%0A        done();%0A  
     

Change done-based mocha tests to use returned promises