Generating structures

Now that we went through basics let's get to more advanced stuff.

Generating nested objects

World doesn't end on flat and unimaginative structures, we can go deeper than that.

fixtureFactory.register('user',{
    type: 'admin',
    firstName: 'Daniel',
    role: {
        id: 'random.uuid',
        name: 'internet.userName'
    }
  });

expect

{
 type: 'admin',
  firstName: 'Daniel',
  role:
  {
     id: '15751f0a-569d-4789-89cc-8f7c8405f007',
     name: 'German_Glover10'
  }
}

Generate arrays

getting arrays with custom number of elements is as well not a problem

fixtureFactory.register('user',{
    type: 'admin',
    firstName: 'Daniel',
    roles: [{
        id: 'random.uuid',
        name: 'internet.userName'
    }, 10]
  });

fixtureFactory.generateOne('user');

expect

{ 
  type: 'admin',
  firstName: 'Daniel',
  roles:
  [
     {
       id: '1b8df9da-3f1a-4f9b-ab96-1de8cc4844c5',
       name: 'Dawn_Dooley30'
     },
     ... 9 more
  ]
}