lib/pathMatch.js
function(jsonBody, lengthSegments) {
  let len = 0

  if (_.isObject(jsonBody)) {
    len = Object.keys(jsonBody).length
  } else {
    len = jsonBody.length
  }

  let msg // message for expectation result
  //TODO: in the future, use expect(jsonBody).to.have.length.below(lengthSegments.count + 1); or similar for non-objects to get better assertion messages
  switch (lengthSegments.sign) {
    case '<=':
      msg =
        'Expected length to be less than or equal to ' +
        lengthSegments.count +
        ', but got ' +
        len
      expect(len).to.be.lessThan(lengthSegments.count + 1, msg)
      break
    case '<':
      msg =
        'Expected length to be less than ' +
        lengthSegments.count +
        ', but got ' +
        len
      expect(len).to.be.lessThan(lengthSegments.count, msg)
      break
    case '>=':
      msg =
        'Expected length to be greater than or equal ' +
        lengthSegments.count +
        ', but got ' +
        len
      expect(len).to.be.greaterThan(lengthSegments.count - 1, msg)
      break
    case '>':
      msg =
        'Expected length to be greater than ' +
        lengthSegments.count +
        ', but got ' +
        len
      expect(len).to.be.greaterThan(lengthSegments.count, msg)
      break
    case null:
      msg = 'Expected length to be ' + lengthSegments.count + ', but got ' + len
      expect(len).to.equal(lengthSegments.count, msg)
      break
  } //end switch
}
function(jsonBody, lengthSegments) {
  let len = 0

  if (_.isObject(jsonBody)) {
    len = Object.keys(jsonBody).length
  } else {
    len = jsonBody.length
  }

  let msg // message for expectation result
  //TODO: in the future, use expect(jsonBody).to.have.length.below(lengthSegments.count + 1); or similar for non-objects to get better assertion messages
  switch (lengthSegments.sign) {
    case '<=':
      msg =
        'Expected length to be less than or equal to ' +
        lengthSegments.count +
        ', but got ' +
        len
      expect(len).to.be.lessThan(lengthSegments.count + 1, msg)
      break
    case '<':
      msg =
        'Expected length to be less than ' +
        lengthSegments.count +
        ', but got ' +
        len
      expect(len).to.be.lessThan(lengthSegments.count, msg)
      break
    case '>=':
      msg =
        'Expected length to be greater than or equal ' +
        lengthSegments.count +
        ', but got ' +
        len
      expect(len).to.be.greaterThan(lengthSegments.count - 1, msg)
      break
    case '>':
      msg =
        'Expected length to be greater than ' +
        lengthSegments.count +
        ', but got ' +
        len
      expect(len).to.be.greaterThan(lengthSegments.count, msg)
      break
    case null:
      msg = 'Expected length to be ' + lengthSegments.count + ', but got ' + len
      expect(len).to.equal(lengthSegments.count, msg)
      break
  } //end switch
}
function ( jsonBody , lengthSegments ) { let len = 0 if ( _ . isObject ( jsonBody ) ) { len = Object . keys ( jsonBody ) . length } else { len = jsonBody . length } let msg // message for expectation result //TODO: in the future, use expect(jsonBody).to.have.length.below(lengthSegments.count + 1); or similar for non-objects to get better assertion messages switch ( lengthSegments . sign ) { case '<=' : msg = 'Expected length to be less than or equal to ' + lengthSegments . count + ', but got ' + len expect ( len ) . to . be . lessThan ( lengthSegments . count + 1 , msg ) break case '<' : msg = 'Expected length to be less than ' + lengthSegments . count + ', but got ' + len expect ( len ) . to . be . lessThan ( lengthSegments . count , msg ) break case '>=' : msg = 'Expected length to be greater than or equal ' + lengthSegments . count + ', but got ' + len expect ( len ) . to . be . greaterThan ( lengthSegments . count - 1 , msg ) break case '>' : msg = 'Expected length to be greater than ' + lengthSegments . count + ', but got ' + len expect ( len ) . to . be . greaterThan ( lengthSegments . count , msg ) break case null : msg = 'Expected length to be ' + lengthSegments . count + ', but got ' + len expect ( len ) . to . equal ( lengthSegments . count , msg ) break } //end switch }
expect length function for matchJSONLength that does the comparison operations
expect length function for matchJSONLength that does the comparison operations