// test/queryController.tests.js
var assert = require('assert'),
  express = require('express'),
  app = express(),
  request = require('supertest'),
  proxyquire = require('proxyquire').noPreserveCache();

describe('queryController', function() {
  describe('when I issue a workitem query for an asset that has no associated commits', function() {
    var esStub = function() {
      this.streams = {
        get: function(args, callback) {
          callback(null, {
            statusCode: '404',
            body: ''
          });
        }
      }
    };

    controller = proxyquire('../../api/queryController', {
      'eventstore-client': esStub
    });

    controller.init(app);

    it('returns a 200 OK response with an empty commits array', function(done) {
      //exercise our api
      request(app)
        .get('/api/query?workitem=123&pageSize=5')
        .end(function(err, res) {
          assert.equal(err, null);
          assert.equal(res.statusCode, 200);
          assert.deepEqual(res.body.commits, []);
          done();
        });
    });
  });

  describe('when I issue a query without a workitem as a parameter', function() {
    controller = proxyquire('../../api/queryController', {
      'eventstore-client': {}
    });

    controller.init(app);

    it('returns a 400 Bad Request response with a error message', function(done) {
      request(app)
        .get('/api/query')
        .end(function(err, res) {
          assert.equal(err, null);
          assert.equal(res.statusCode, 400);
          assert.equal(res.body.error, 'Parameter workitem is required');
          done();
        });
    });
  });
});
@@ -30,22 +30,20 @@
 .js%0Avar 
-assert
+chai
  = requi
@@ -50,15 +50,39 @@
 re('
-assert'
+chai'),%0A  should = chai.should(
 ),%0A 
@@ -131,16 +131,110 @@
 ress(),%0A
+  sinon = require('sinon'),%0A  sinonChai = require('sinon-chai'),%0A  _ = require('underscore'),%0A
   reques
@@ -316,16 +316,71 @@
 che();%0A%0A
+chai.use(sinonChai);%0Achai.config.includeStack = true;%0A%0A
 describe
@@ -1078,123 +1078,120 @@
     
-assert.equal(err, null);%0A          assert.equal(res.statusCode, 200);%0A          assert.deepEqual(res.body.commits, 
+should.not.exist(err);%0A          res.statusCode.should.equal(200);%0A          res.body.commits.should.deep.equal(
 %5B%5D);
@@ -1620,72 +1620,69 @@
     
-assert.equal(err, null);%0A          assert.equal(res.statusCode, 
+should.not.exist(err);%0A          res.statusCode.should.equal(
 400)
@@ -1697,21 +1697,8 @@
     
-assert.equal(
 res.
@@ -1707,18 +1707,30 @@
 dy.error
-, 
+.should.equal(
 'Paramet

Refactor tests to use chai/should :-D S-50752