> For the complete documentation index, see [llms.txt](https://briebug.gitbook.io/ngrx-workshop/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://briebug.gitbook.io/ngrx-workshop/testing/testing-factory.md).

# Testing Factory

```typescript
// State Factory
const createUser = ({
 id = 0,
 firstName = '',
 lastName = '',
 userName = ''
} = {}): User => ({
 id: id,
 firstName: firstName || 'firstName',
 lastName: lastName || `lastName`,
 userName: userName || `${firstName}.${lastName}`
});

const createUsersState = ({
entities = {
'1': createUser({ id: 1, firstName: 'Bob' }), 
'2': createUser({ id: 2, firstName: 'Sue' }), 
'3': createUser({ id: 3, firstName: 'Mary' })
 	},
 	ids = ['1', '2', '3'], 
selectedId = 0, 
loading = false, 
error = ''
} = {}) => ({
 users: {
   ids,
   entities,
   selectedId,
   loading,
   error
 }
});	
```
