customAsserts/documentAssertions.js
function assertSameObjectIdArray(actual, expected, msg) {
  assert(Array.isArray(actual), 'assertSameObjectIdArray: First argument is not an Array.')
  assert(Array.isArray(expected), 'assertSameObjectIdArray: Second argument is not an Array.')
  assert(size(actual) > 0 || size(expected) > 0, 'assertSameObjectIdArray: Received two empty Arrays.')
  assert.strictEqual(size(actual), size(expected), 'assertSameObjectIdArray: arrays different sizes')
  const parseIds = flow(map(stringifyObjectId), sortBy(identity))
  try { parseIds(actual) } catch (err) { throw Error(`assertSameObjectIdArray 1st argument: ${err.message}`) }
  try { parseIds(expected) } catch (err) { throw Error(`assertSameObjectIdArray 2nd argument: ${err.message}`) }
  assert.deepStrictEqual(parseIds(actual), parseIds(expected), msg)
}
function assertSameObjectIdArray(actual, expected, msg) {
  assert(Array.isArray(actual), 'assertSameObjectIdArray: First argument is not an Array.')
  assert(Array.isArray(expected), 'assertSameObjectIdArray: Second argument is not an Array.')
  assert(size(actual) > 0 || size(expected) > 0, 'assertSameObjectIdArray: Received two empty Arrays.')
  assert.strictEqual(size(actual), size(expected), 'assertSameObjectIdArray: arrays different sizes')
  const parseIds = flow(map(stringifyObjectId), sortBy(identity))
  try { parseIds(actual) } catch (err) { throw Error(`assertSameObjectIdArray 1st argument: ${err.message}`) }
  try { parseIds(expected) } catch (err) { throw Error(`assertSameObjectIdArray 2nd argument: ${err.message}`) }
  assert.deepStrictEqual(parseIds(actual), parseIds(expected), msg)
}
function assertSameObjectIdArray ( actual , expected , msg ) { assert ( Array . isArray ( actual ) , 'assertSameObjectIdArray: First argument is not an Array.' ) assert ( Array . isArray ( expected ) , 'assertSameObjectIdArray: Second argument is not an Array.' ) assert ( size ( actual ) > 0 || size ( expected ) > 0 , 'assertSameObjectIdArray: Received two empty Arrays.' ) assert . strictEqual ( size ( actual ) , size ( expected ) , 'assertSameObjectIdArray: arrays different sizes' ) const parseIds = flow ( map ( stringifyObjectId ) , sortBy ( identity ) ) try { parseIds ( actual ) } catch ( err ) { throw Error ( ` ${ err . message } ` ) } try { parseIds ( expected ) } catch ( err ) { throw Error ( ` ${ err . message } ` ) } assert . deepStrictEqual ( parseIds ( actual ) , parseIds ( expected ) , msg ) }
Throws if the given actual and expected arrays of ObjectIds don't match.
@method assertSameDocumentIdArray
@param {ObjectId[]} actual - Array of ObjectId
@param {ObjectId[]} expected - Array of ObjectId
@param {String} msg - Optional custom error message
@return {undefined} - Throws if assertions fail
Throws if the given actual and expected arrays of ObjectIds don t match .