<commit_before>const routeHelper = require('../../helpers/routes/route-helper')
const supertest = require('supertest')
const proxyquire = require('proxyquire')
const expect = require('chai').expect
const sinon = require('sinon')
require('sinon-bluebird')

const workloadTypes = require('../../../app/constants/workload-type')

// test data
const OFFENDER_MANAGER_CAPACITY_URI = '/' + workloadTypes.PROBATION + '/offender-manager/1/caseload-capacity'
const REGION_CAPACITY_URI = '/' + workloadTypes.PROBATION + '/region/1/caseload-capacity'
const REGION_CAPACITY_URI_MISSING_ID = '/' + workloadTypes.PROBATION + '/region/caseload-capacity'
const TEAM_CAPACITY_URI = '/' + workloadTypes.PROBATION + '/team/1/caseload-capacity'
const LDU_CAPACITY_URI = '/' + workloadTypes.PROBATION + '/ldu/1/caseload-capacity'

const CAPACITY_FROM_DAY = 'capacity-from-day='
const CAPACITY_FROM_MONTH = 'capacity-from-month='
const CAPACITY_FROM_YEAR = 'capacity-from-year='

const CAPACITY_TO_DAY = 'capacity-to-day='
const CAPACITY_TO_MONTH = 'capacity-to-month='
const CAPACITY_TO_YEAR = 'capacity-to-year='

describe('/caseload-capacity', function () {
  var app
  var getCapacityStub
  var getOutstandingReportsStub
  var getSubNavStub
  var getLastUpdated
  var capacityStubResult = {title: 'Test', capacityTable: {}, subNav: [{}]}
  var authorisationService
  authorisationService = {
    assertUserAuthenticated: sinon.stub()
  }
  beforeEach(function () {
    getCapacityStub = sinon.stub()
    getOutstandingReportsStub = sinon.stub().resolves()
    getSubNavStub = sinon.stub()
    getLastUpdated = sinon.stub().resolves(new Date(2017, 11, 1))
    var route = proxyquire(
      '../../../app/routes/capacity-route', {
        '../services/get-capacity-view': getCapacityStub,
        '../services/get-outstanding-reports': getOutstandingReportsStub,
        '../authorisation': authorisationService,
        '../services/get-sub-nav': getSubNavStub,
        '../services/data/get-last-updated': getLastUpdated
      })
    app = routeHelper.buildApp(route)
  })

  describe('/probation/ldu/{id}/caseload-capacity', function () {
    it('should respond with 200 when ldu and id is used with date parameters', function () {<commit_msg>WMT0092: Fixing capacity route unit test<commit_after>const routeHelper = require('../../helpers/routes/route-helper')
const supertest = require('supertest')
const proxyquire = require('proxyquire')
const expect = require('chai').expect
const sinon = require('sinon')
require('sinon-bluebird')

const workloadTypes = require('../../../app/constants/workload-type')

// test data
const OFFENDER_MANAGER_CAPACITY_URI = '/' + workloadTypes.PROBATION + '/offender-manager/1/caseload-capacity'
const REGION_CAPACITY_URI = '/' + workloadTypes.PROBATION + '/region/1/caseload-capacity'
const REGION_CAPACITY_URI_MISSING_ID = '/' + workloadTypes.PROBATION + '/region/caseload-capacity'
const TEAM_CAPACITY_URI = '/' + workloadTypes.PROBATION + '/team/1/caseload-capacity'
const LDU_CAPACITY_URI = '/' + workloadTypes.PROBATION + '/ldu/1/caseload-capacity'

const CAPACITY_FROM_DAY = 'capacity-from-day='
const CAPACITY_FROM_MONTH = 'capacity-from-month='
const CAPACITY_FROM_YEAR = 'capacity-from-year='

const CAPACITY_TO_DAY = 'capacity-to-day='
const CAPACITY_TO_MONTH = 'capacity-to-month='
const CAPACITY_TO_YEAR = 'capacity-to-year='

describe('/caseload-capacity', function () {
  var app
  var getCapacityStub
  var getOutstandingReportsStub
  var getSubNavStub
  var getLastUpdated
  var capacityStubResult = {title: 'Test', capacityTable: {}, subNav: [{}]}
  var authorisationService
  var getCaseDetailsStub
  authorisationService = {
    assertUserAuthenticated: sinon.stub()
  }
  beforeEach(function () {
    getCapacityStub = sinon.stub()
    getCaseDetailsStub = sinon.stub.resolves()
    getOutstandingReportsStub = sinon.stub().resolves()
    getSubNavStub = sinon.stub()
    getLastUpdated = sinon.stub().resolves(new Date(2017, 11, 1))
    var route = proxyquire(
      '../../../app/routes/capacity-route', {
        '../services/get-capacity-view': getCapacityStub,
        '../services/get-outstanding-reports': getOutstandingReportsStub,
        '../services/get-case-details-view': getCaseDetailsStub,
        '../authorisation': authorisationService,
        '../services/get-sub-nav': getSubNavStub,
        '../services/data/get-last-updated': getLastUpdated
      })
    app = routeHelper.buildApp(route)
  })

  describe('/probation/ldu/{id}/caseload-capacity', function () {
    it('should respond with 200 when ldu and id is used with date parameters', function () {
{'fraction_non_alphanumeric': 0.14189774696707105, 'fraction_numerical': 0.006932409012131715, 'mean_word_length': 4.3068965517241375, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '354593', 'n_tokens_mistral': 1507, 'n_tokens_neox': 1509, 'n_words': 263}