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
+10-10
Original file line number
Diff line number
Diff line change
@@ -29,9 +29,9 @@
29
29
30
30
## About
31
31
32
-
Have you ever needed to mock something that has hundreds or thousands of nested properties and functions? You don't need all of those to be implemented, just exist so the code doesn't crash. This is the solution.
32
+
Have you ever wanted to mock something that has lots of nested properties and functions? You don't need all of those to be implemented. You just want them to exist so the code doesn't crash. This is the solution.
33
33
34
-
Recursive Proxy Mock is a [JavaScript Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) that can handle literally anything. This is best explained with examples, read on!
34
+
Recursive Proxy Mock is a [JavaScript Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) that can handle literally anything. This is best explained with examples. Read on!
Main function to create the recursive proxy mock object.
137
137
138
138
-`overrides` - _\[optional]_ - an array of objects that contain `path` and `value`.
139
-
-`path` - see the [ProxyPath section](#ProxyPath) for more details.
139
+
-`path` - see the [ProxyPath section](#proxypath) for more details.
140
140
-`value` - the value to return instead of another recursive proxy. This needs to match the type of the path. So if your path ends in `ProxySymbol.APPLY` this value must be a function which will be called with whatever arguments the proxy was called with.
141
141
142
-
See [Example Above](#Override-the-default-proxy-behavior-with-custom-values) for more details.
142
+
See [Example Above](#override-the-default-proxy-behavior-with-custom-values) for more details.
143
143
144
144
#### TypeScript Support
145
145
@@ -174,15 +174,15 @@ These symbols are used to construct paths for the following functions:
174
174
Function to check if a certain path was ever visited. Useful in conjunction with test assertions.
175
175
176
176
-`proxy` - the root proxy object that was returned from `recursiveProxyMock`
177
-
-`path` - see the [ProxyPath section](#ProxyPath) for more details.
177
+
-`path` - see the [ProxyPath section](#proxypath) for more details.
178
178
- Returns: `true` if the specified path has ever been visited on the proxy object, `false` if not.
Function to check if a certain path was ever called (as a function or class constructor). Useful in conjunction with test assertions. Very similar to `hasPathBeenVisited` but specific for method calls and designed to be easier to use than parsing `getVisitedPathData` yourself.
183
183
184
184
-`proxy` - the root proxy object that was returned from `recursiveProxyMock`
185
-
-`path` - see the [ProxyPath section](#ProxyPath) for more details. The path must end in `ProxySymbol.APPLY` or `ProxySymbol.CONSTRUCT`.
185
+
-`path` - see the [ProxyPath section](#proxypath) for more details. The path must end in `ProxySymbol.APPLY` or `ProxySymbol.CONSTRUCT`.
186
186
-`args` - an array of arguments that should have been passed to the specified path
187
187
- Returns: `true` if the specified path has ever been called on the proxy object, `false` if not.
188
188
@@ -191,7 +191,7 @@ Function to check if a certain path was ever called (as a function or class cons
191
191
Function to get details about every time a path was visited. Useful in conjunction with test assertions to get the number of visits, arguments passed, etc.
192
192
193
193
-`proxy` - the root proxy object that was returned from `recursiveProxyMock`
194
-
-`path` - see the [ProxyPath section](#ProxyPath) for more details.
194
+
-`path` - see the [ProxyPath section](#proxypath) for more details.
195
195
- Returns: Array of `ProxyData` objects, one for each time the path was visited on the proxy object. `null` if it was never visited.
196
196
197
197
#### ProxyData
@@ -213,16 +213,16 @@ A `ProxyData` object contains any relevant details about the operation. For exam
A debug function which lists the raw "proxy stack" of every operation that was performed on the mock. This is an array of [ProxyData](#ProxyData) objects which have metadata that is used to power all of the other functions. For example, every object has a `parent` property which contains a number. This number will be the same as some other object's `self` property. Using those two values you can construct a tree containing every path that was accessed on the object.
216
+
A debug function which lists the raw "proxy stack" of every operation that was performed on the mock. This is an array of [ProxyData](#proxydata) objects which have metadata that is used to power all of the other functions. For example, every object has a `parent` property which contains a number. This number will be the same as some other object's `self` property. Using those two values you can construct a tree containing every path that was accessed on the object.
217
217
218
218
This is exposed primarily for debugging or curiosity and shouldn't be relied on. If you find yourself needing to use the data here, [create an Issue](https://github.com/CreativeTechGuy/recursive-proxy-mock/issues/new/choose) explaining your use-case and we may add a function to support that directly.
219
219
220
220
-`proxy` - the root proxy object that was returned from `recursiveProxyMock`
221
-
- Returns: Array of [ProxyData](#ProxyData) objects for every operation that was performed on the mock.
221
+
- Returns: Array of [ProxyData](#proxydata) objects for every operation that was performed on the mock.
222
222
223
223
### ProxyPath
224
224
225
-
Whenever a method accepts a `path` it is an array of properties and symbols to define a request path on the mock object. (See [ProxySymbol](#ProxySymbol) for more details.)
225
+
Whenever a method accepts a `path` it is an array of properties and symbols to define a request path on the mock object. (See [ProxySymbol](#proxysymbol) for more details.)
0 commit comments