williamkapke / mongo-mock

Let's pretend we have a real MongoDB
MIT License
240 stars 75 forks source link

Fix false positive fields options #142

Closed LinusU closed 3 years ago

LinusU commented 3 years ago

Before this the following valid call to find:

.find(
  { foo: 'bar' },
  { sort: { orderPriority: -1, name: 1 } }
)

would be wrongly interpreted as:

{
  query: { foo: 'bar' },
  fields: { sort: { orderPriority: -1, name: 1 } },
  // ...
}

This patch fixes that by only setting fields when it's explicitly passed in the given signature.

LinusU commented 3 years ago

The check actually did pass on the last one, but Travis failed to report it. I'll force push the same commit to restart Travis...