Open zakgof opened 6 years ago
thx for reporting this @zakgof!, I will look into it...
BUG FIXING
Reported:
Problem:
Possible cause: (debugging, takes most of the time)
createData
functions assumes that values in the schema are primitives or functions, https://github.com/nshimiye/react-mock/blob/master/src/react-mock/data-generator.ts#L29-L40
FakerGenerator.next(1, {key : Faker.lorem.word, inner: {prop1: Faker.lorem.word, prop2: Faker.lorem.sentence}})
[{ "id":"ea4a378f-9d25-4a23-9109-af06f5dd656c", "key":"molestiae", "inner":{}}]
[{ "id":"ea4a378f-9d25-4a23-9109-af06f5dd656c", "key":"molestiae", "inner":{ “prop1”: “distinctio”, “prop2”: “veniam” }}]
Proposed solution:
createData
if current value in the loop is an object or an array.
When I'm trying to mock a structure like this:
generator.next(3, {key : Faker.lorem.word, inner: {prop1: Faker.lorem.word, prop2: Faker.lorem.sentence}})
the inner properties prop1 and prop2 do not get generated:
{"id":"0695987d-8dbc-4e1c-81a6-2de839b1eb03","key":"vel","inner":{}}