I am trying to unit test the getAll
method on this class:
module.exports = class BookController {
static async getAll() {
return await Book.query()
.eager('reviews');
}
};
Book is a Objection model.
How I'd like to test it is I want to fake the response from Book.query().eager()
with my own data, since I can never verify what's in the database. For it to be a true unit test, should I just be testing that the Book.query()
method is called? Or should I be testing that the returned data since that's the contract of the getAll()
method? I'm really unsure how I should be stubbing this out.
via lgh
No comments:
Post a Comment