elections-cpl.api.hscc.bdpa.org • Docs
elections-cpl.api.hscc.bdpa.org / lib/mongo-common / generateMockSensitiveObjectId
generateMockSensitiveObjectId():
ObjectId
Calls new ObjectId(...)
explicitly passing mockDateNowMs as the
inception time, which is the same thing that ObjectId does internally
with the real Date.now
.
This should only be used in modules with import side-effects that execute
before useMockDateNow
is called later in downstream code. If you are
unsure, you probably don't need to use this function and should just call
new ObjectId()
instead.
The point of this function is to avoid race conditions when mocking parts of the Date object that sometimes resulted in later calls to ObjectId generating IDs that were less than the IDs generated before it.
ObjectId