-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: How to create a factory outputs tuples? #72
Comments
Hi, sorry for the slow response. I checked and tuples work as members of an object, so if nothing else you can create a pointless wrapper around the actual tuple, e.g. const factory = Sync.makeFactory<{ foo: [number, number] }>(
{
_: Sync.each((seq) => [seq * 2, seq * 2 + 1]),
},
{ startingSequenceNumber: 1 }
);
const tupleBuilder = () => factory.build()._;
const value = tupleBuilder();
expect(value.foo).toEqual([2, 3]); I don't have a good solution (yet) for giving a different Generator to each element of the tuple, although there are reasonable ways around this by passing the seqNum down to each element. Also, this be aided by the work I'm trying to do to address #55. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently the builder interface looks like this:
Which seems like only could describe objects. Would it be possible to create a factory generates tuples? Tuple has fixed length (
[number, number]
), where array has arbitrary length (number[]
).What I'm trying to get is a
Factory<[number, number]>
. The best version I could get is:Which is not randomized, and calling
factory.build()
gives me an object:Any suggestion?
The text was updated successfully, but these errors were encountered: