async function getData (price, before, after) {
let query = User.query().select('id', 'price', 'age')
query = price ? query.where('price', '=', price) : query
query = after ? query.where('age', '>=', after) : query
query = before ? query.where('age', '<=', before) : query
query = query.orderBy('age', 'desc')
return query
}
this.sinon.stub(User, 'query').returns({
select: this.sinon.stub().returnsThis(),
where: this.sinon.stub().returnsThis(),
orderBy: this.sinon.stub().returns(records)
})
How to stub the model select, where method
23 Friday Jun 2023
Posted Uncategorized
in