Skip to content

Commit

Permalink
[CHORE]_Create_Table_of_Contents_for_README
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaskiewicz committed Nov 26, 2017
1 parent 1820d26 commit 1a107b9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Renamed `FactoryStamp` to `FactoryTemplate` to be more consistent in naming
- Updated template storage to use a Set
- Made definition of `FactoryMateAware` ctor more succinct in its parameter type definition (no longer uses `any`)
- Added Table of Contents to README

## [v1.3.1](https://github.com/rwaskiewicz/factory-mate/compare/v1.3.0...v1.3.1) - September 28, 2017
- Refactored `FactoryStamp` into it's own class for storing templates
Expand Down
24 changes: 21 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,31 @@
FactoryMate is a TypeScript-based fixture library for instantiating domain objects for testing purposes, inspired by
the [Factory Duke](https://github.com/regis-leray/factory_duke) project.


## Table of Contents
- **[Getting Started](#getting-started)**<br>
- **[Example Project](#example-project)**<br>
- **[Usage](#usage)**<br>
- **[Factory Classes](#factory-classes)**<br>
- **[Additional Building Methods](#additional-building-methods)**<br>
- **[Named Templates](#named-templates)**<br>
- **[Overriding a Template's Variables](#overriding-a-templates-variables)**<br>
- **[Building Many of the Same Object](#building-many-of-the-same-object)**<br>
- **[Sequence Generation](#sequence-generation)**<br>
- **[NumberGenerator](#numbergenerator)**<br>
- **[ProvidedValueGenerator](#providedvaluegenerator)**<br>
- **[Recipes](#recipes)**<br>
- **[Creating a Random Number Generator](#creating-a-random-number-generator)**<br>
- **[License](#license)**<br>

## Getting Started

FactoryMate can be installed via NPM:
```
npm install --save-dev factory-mate
```

## Example
## Example Project
An example project using FactoryMate can be found here: [FactoryMateConsumer](https://github.com/rwaskiewicz/factory-mate-consumer)

## Usage
Expand Down Expand Up @@ -115,7 +132,8 @@ To build several objects of the same type:
const groceryItems: GroceryItem[] = FactoryMate.buildMany(GroceryItem.name, 3);
```

### Sequence Generation
## Sequence Generation
### NumberGenerator
FactoryMate supports infinite, numerical sequence generation via the ```NumberGenerator``` class. This can be helpful for the purposes of generating ID values for domain objects to better represent real world scenarios (e.g. IDs in a data store)

In order to add sequential generation support to an entity, it can be imported into it's factory as such:
Expand Down Expand Up @@ -151,7 +169,7 @@ console.log(JSON.stringify(groceryItem1)); //'{"id":1,"groceryName":"chewy cooki
console.log(JSON.stringify(groceryItem2)); //'{"id":2,"groceryName":"chewy cookies"}'
console.log(JSON.stringify(groceryItem3)); //'{"id":3,"groceryName":"chewy cookies"}'
```
#### Changing sequence values
#### Changing Numerical Sequence Values
By default, ```NumberGenerator``` starts at a value of 1 and increments by 1. These values can be altered at instantiation time if desired
``` typescript
// Start at one, increment by one: 1, 2, 3 ...
Expand Down

0 comments on commit 1a107b9

Please sign in to comment.