From 0ef23b6d864e71b92b431a48cf18fb0d34724c57 Mon Sep 17 00:00:00 2001 From: jlenon7 Date: Thu, 11 Jan 2024 09:32:58 +0000 Subject: [PATCH 1/2] feat(test): explain that mocking driver also change models --- docs/testing/mocking.mdx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/testing/mocking.mdx b/docs/testing/mocking.mdx index 279b0adc..91186978 100644 --- a/docs/testing/mocking.mdx +++ b/docs/testing/mocking.mdx @@ -1041,8 +1041,8 @@ to clean your mocks in each test 👍 ### Mocking the `find()` method Imagine that our `UserService` has a method called `findById()` -that is responsible to find a user in database by the id. To -mock this scenario, we could do the following: +that is responsible to find a user in database by the id using +a `User` model. To mock this scenario, we could do the following: ```typescript import { UserService } from '#app/services/UserService' @@ -1079,8 +1079,8 @@ export default class UserServiceTest { ### Mocking the `create()` method Now imagine that our `UserService` has a method called `create()` -that is responsible to create a user in database. To mock this -scenario, we could do the following: +that is responsible to create a user in database using a `User` +model. To mock this scenario, we could do the following: ```typescript import { UserService } from '#app/services/UserService' @@ -1118,6 +1118,9 @@ export default class UserServiceTest { :::tip -You are able to mock any of the methods of the database [query builder.](/docs/database/query-builder) +Mocking the methods of the `Database.driver` property gaves you +power to change the behavior of models and also `Database` +facade calls. You are able to mock any method of the +database [query builder](/docs/database/query-builder) ::: From a5407cf398bfcfbaa1870ead87a3a66efde19517 Mon Sep 17 00:00:00 2001 From: jlenon7 Date: Thu, 11 Jan 2024 09:34:04 +0000 Subject: [PATCH 2/2] fix(test): grammar --- docs/testing/mocking.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/testing/mocking.mdx b/docs/testing/mocking.mdx index 91186978..54417da6 100644 --- a/docs/testing/mocking.mdx +++ b/docs/testing/mocking.mdx @@ -1042,7 +1042,7 @@ to clean your mocks in each test 👍 Imagine that our `UserService` has a method called `findById()` that is responsible to find a user in database by the id using -a `User` model. To mock this scenario, we could do the following: +an `User` model. To mock this scenario, we could do the following: ```typescript import { UserService } from '#app/services/UserService' @@ -1079,7 +1079,7 @@ export default class UserServiceTest { ### Mocking the `create()` method Now imagine that our `UserService` has a method called `create()` -that is responsible to create a user in database using a `User` +that is responsible to create a user in database using an `User` model. To mock this scenario, we could do the following: ```typescript