Skip to content
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

Generating deeper structures #28

Open
zakgof opened this issue Aug 13, 2018 · 2 comments
Open

Generating deeper structures #28

zakgof opened this issue Aug 13, 2018 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@zakgof
Copy link

zakgof commented Aug 13, 2018

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":{}}

@nshimiye
Copy link
Owner

thx for reporting this @zakgof!, I will look into it...

@nshimiye nshimiye added the enhancement New feature or request label Jan 23, 2019
@nshimiye nshimiye self-assigned this Jan 23, 2019
nshimiye pushed a commit that referenced this issue Jan 23, 2019
With the need for javascript based tests that are executed in the browser, we are adding cypress
test runner to make it easy to run these tests

re #28
@nshimiye
Copy link
Owner

BUG FIXING

Reported:

Problem:

  • NOTE: How you understand the reported bug. (basically a rephrase of Reported)
  • Example: I cannot generate records from schemas with deeper structures.

Possible cause: (debugging, takes most of the time)

  • NOTE: Look at the code and see what piece of code produces current behavior.
  • Format:
    • scenario: What you did (usually helps, if possible, to isolate that piece of code in a fixed environment)
    • current behavior: What happened (results of a function, state of UI, …)
    • desired behavior: What should have happened (results of a function, state of UI, …)
  • Example: 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
    • scenario: FakerGenerator.next(1, {key : Faker.lorem.word, inner: {prop1: Faker.lorem.word, prop2: Faker.lorem.sentence}})
    • current behavior: [{ "id":"ea4a378f-9d25-4a23-9109-af06f5dd656c", "key":"molestiae", "inner":{}}]
    • desired behavior: [{ "id":"ea4a378f-9d25-4a23-9109-af06f5dd656c", "key":"molestiae", "inner":{ “prop1”: “distinctio”, “prop2”: “veniam” }}]

Proposed solution:

  • NOTE: Describe what changes can be made to the piece of code, in order to produce desired behavior.
  • Example: Add a recursive call for createData if current value in the loop is an object or an array.

nshimiye pushed a commit that referenced this issue Jan 25, 2019
use recursion to execute functions inside inner objects of the provided schema

BREAKING CHANGE: react-mock is able to parse both inner objects and arrays

fix #28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants