<commit_before>// test/queryController.tests.js
var chai = require('chai'),
  should = chai.should(),
  express = require('express'),
  app = express(),
  sinon = require('sinon'),
  sinonChai = require('sinon-chai'),
  _ = require('underscore'),
  request = require('supertest'),
  proxyquire = require('proxyquire').noPreserveCache(),
  /* We must provide some dummy values here for the module: */
  config = require ('../../config');
  config.eventStorePassword = '<PASSWORD>';
  config.eventStoreUser = 'admin';
  config.eventStoreBaseUrl = 'http://nothing:7887';

chai.use(sinonChai);
chai.config.includeStack = true;

var eventStoreClient = {
  streams: {
    get: sinon.stub()
  }
}

controller = proxyquire('../../api/queryController', {
  './helpers/eventStoreClient': eventStoreClient
});

controller.init(app);

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) {
  //         should.not.exist(err);
  //         res.statusCode.should.equal(200);
  //         res.body.commits.should.deep.equal([]);
  //         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) {
  //         should.not.exist(err);
  //         res.statusCode.should.equal(400);
  //         res.body.error.should.equal('Parameter workitem is required');
  //         done();
  //       });
  //   });
  // });

  describe('when I issue a query with a workitem=all as a parameter', function() {
    var mockData = {
      body: '{ "entries": [] }'
    }

    beforeEach(function() {
      eventStoreClient.streams.get.callsArgWith(1, null, mockData);
    })<commit_msg>WIP: Bring back one of the tests we had temporarily commented out<commit_after>// test/queryController.tests.js
var chai = require('chai'),
  should = chai.should(),
  express = require('express'),
  app = express(),
  sinon = require('sinon'),
  sinonChai = require('sinon-chai'),
  _ = require('underscore'),
  request = require('supertest'),
  proxyquire = require('proxyquire').noPreserveCache(),
  /* We must provide some dummy values here for the module: */
  config = require ('../../config');
  config.eventStorePassword = '<PASSWORD>';
  config.eventStoreUser = 'admin';
  config.eventStoreBaseUrl = 'http://nothing:7887';

chai.use(sinonChai);
chai.config.includeStack = true;

var eventStoreClient = {
  streams: {
    get: sinon.stub()
  }
}

controller = proxyquire('../../api/queryController', {
  './helpers/eventStoreClient': eventStoreClient
});

controller.init(app);

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) {
  //         should.not.exist(err);
  //         res.statusCode.should.equal(200);
  //         res.body.commits.should.deep.equal([]);
  //         done();
  //       });
  //   });
  // });

  describe('when I issue a query without a workitem as a parameter', function() {

    it('returns a 400 Bad Request response with a error message', function(done) {
      request(app)
        .get('/api/query')
        .end(function(err, res) {
          should.not.exist(err);
          res.statusCode.should.equal(400);
          res.body.error.should.equal('Parameter workitem is required');
          done();
        });
    });
  });

  describe('when I issue a query with a workitem=all as a parameter', function() {
    var mockData = {
      body: '{ "entries": [] }'
    }

    beforeEach(function() {
      eventStoreClient.streams.get.callsArgWith(1, null, mockData);
    })
{'fraction_non_alphanumeric': 0.17545560294687865, 'fraction_numerical': 0.009305932531989143, 'mean_word_length': 2.332687338501292, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5438871', 'n_tokens_mistral': 1637, 'n_tokens_neox': 1591, 'n_words': 337}