Files
habitica/test/helpers/mongoose.helper.js
Phillip Thelen cfbfec34aa Allow gems and subs to be gifted through in-app-purchases (#10892)
* Allow gems to be gifted through IAPs

* implement non recurring IAP subscriptions

* fix localization issue in error

* fix non renewing subscription handling

* Fix lint error

* fix tests

* move findbyId mock to helper file

* undo package-lock changes

* Fix lint error
2018-12-23 19:20:14 +01:00

21 lines
397 B
JavaScript

import mongoose from 'mongoose';
export async function mockFindById (response) {
const mockFind = {
select () {
return this;
},
lean () {
return this;
},
exec () {
return Promise.resolve(response);
},
};
sinon.stub(mongoose.Model, 'findById').returns(mockFind);
}
export function restoreFindById () {
return mongoose.Model.findById.restore();
}