You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-27Lines changed: 16 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,8 +49,14 @@ and add the previous file in `jest.config.json`
49
49
```
50
50
51
51
## 🏰 Builder API
52
-
#### withMocks
53
-
By using this you let your components know what `http requests` will respond. It works matching the request url which is `host` + `path`, the request `method` and the `requestBody`. All three need to match, otherwise it will raise an exception to let you know that one of your components is doing an `http request` that is not being handled.
52
+
53
+
#### withMocks (Deprecated)
54
+
55
+
It has the same API than the withNetwork builder. The main difference between them is that withMocks will fail if a given request, done by the production code, is not set up in the `responses object`.
56
+
57
+
#### withNetwork
58
+
By using this feature you can configure the responses for your `http requests`. If your component is making a request that is not set up in the `responses object`, it will not be validated and it will return an empty response with code 200.
59
+
54
60
```
55
61
import { wrap } from '@mercadona/mo.library.burrito'
56
62
@@ -64,35 +70,18 @@ const responses = {
64
70
}
65
71
66
72
wrap(MyComponent)
67
-
.withMocks(responses)
73
+
.withNetwork(responses)
68
74
.mount()
69
75
```
70
-
`host`, `method` and `status` will be the same most of the cases, we don't want to specify them every single time.
71
-
72
-
By default 🌯 burrito is testing the query params in your responses, but if you want to ignore it you must add the `handleQueryParams` param in the config and to test it you can use the `catchParams` property in the request, like this:
73
-
74
-
```
75
-
import { configure } from '@mercadona/mo.library.burrito'
76
-
77
-
configure({ handleQueryParams: true })
78
76
79
-
wrap(MyComponentUsingQueryParams)
80
-
.withMocks({
81
-
path: '/path/with/query/params/?myAwesome=param',
82
-
responseBody: '15',
83
-
catchParams: true,
84
-
})
85
-
.mount()
86
-
```
87
-
88
-
While `host` has a default value specified by using the `configure`:
77
+
You can specify the default `host` via configuration:
89
78
```
90
79
import { configure } from '@mercadona/mo.library.burrito'
0 commit comments