Closed shaabans closed 4 years ago
Hi! Apologies it has taken us some time to look into this - one of the core maintainers will debug and should have a response by tomorrow!
Thanks Mike, I appreciate how response you always are to questions. I'd be happy to submit a documentation update PR once I get my brain around how to use u.array.
Hi! unmock
does not currently have a global override for minItems
of an array, so it needs to be specified on a property-by-property basis. In this case, you'd need to specify it for the cases
property like so:
myApi.state(
withCodes(200),
responseBody({ lens: ["cases"] }).minItems(20)
);
In general, lens
takes an array that drills down to the property. So, for example, if cases
were nested in an object, ie {people: { cases: []}}
, the lens would be { lens: [ "people", "cases"] }
. I hope that's helpful, and if you have any suggestions for the API please let us know!
This is perfect, exactly what I wanted to do!
I was going to suggest an update to https://www.unmock.io/docs/setting-state but it looks like there's already an example of using lens
near the bottom which I must have missed.
Thanks again for the quick reply, knowing how to do this really helps us use Unmock.
I've been trying to understand how to control the number of items coming back in an array. Here's an example:
The following does not change how many
cases
items are returned:Maybe it shouldn't work since I'm not using
u.array
at the top level of the response, in which case can anyone provide a tip on how to specify which response element you want to setminItems
on?Much thanks in advance!