factory-mate
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -1,3 +0,3 @@ | ||
export interface Generator { | ||
nextValue(): number; | ||
export interface Generator<T> { | ||
nextValue(): T; | ||
} |
import { Generator } from './Generator'; | ||
export declare class NumberGenerator implements Generator { | ||
export declare class NumberGenerator implements Generator<number> { | ||
private currentValue; | ||
@@ -4,0 +4,0 @@ private increment; |
export * from './factoryMate/FactoryMateAware'; | ||
export * from './factoryMate/FactoryMate'; | ||
export * from './factoryMate/generators/NumberGenerator'; | ||
export * from './factoryMate/generators/ProvidedValueGenerator'; |
@@ -9,1 +9,2 @@ "use strict"; | ||
__export(require("./factoryMate/generators/NumberGenerator")); | ||
__export(require("./factoryMate/generators/ProvidedValueGenerator")); |
{ | ||
"name": "factory-mate", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "TypeScript library for building domain objects", | ||
@@ -21,3 +21,5 @@ "keywords": [ | ||
"testSingleRun": "karma start --single-run", | ||
"package": "tsc && npm pack" | ||
"package": "rm -rf ./dist && tsc && npm pack", | ||
"report-coverage": "cat ./coverage/lcov/lcov.info | coveralls" | ||
}, | ||
@@ -33,2 +35,3 @@ "author": "Ryan Waskiewicz", | ||
"base64-js": "^1.0.2", | ||
"coveralls": "^2.13.1", | ||
"ieee754": "^1.1.4", | ||
@@ -35,0 +38,0 @@ "isarray": "^1.0.0", |
# FactoryMate | ||
[![Build Status](https://travis-ci.org/rwaskiewicz/factory-mate.svg?branch=develop)](https://travis-ci.org/rwaskiewicz/factory-mate) | ||
[![npm version](https://badge.fury.io/js/factory-mate.svg)](https://badge.fury.io/js/factory-mate) | ||
[![Coverage Status](https://coveralls.io/repos/github/rwaskiewicz/factory-mate/badge.svg?branch=develop)](https://coveralls.io/github/rwaskiewicz/factory-mate?branch=develop) | ||
@@ -88,3 +89,3 @@ FactoryMate is a TypeScript-based fixture library for instantiating domain objects for testing purposes, inspired by | ||
### Sequence Generation | ||
FactoryMate supports 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. keys in from a datastore) | ||
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. keys in a data store) | ||
@@ -135,2 +136,14 @@ In order to add sequential generation support to an entity, it can be imported into it's factory as such: | ||
### ProvidedValueGenerator | ||
FactoryMate also supports finite sequence generation by means of the `ProvidedValueGenerator` class. `ProvidedValueGenerator` is capable of returning values from an `Array` of numbers, strings, objects, etc. that was provided to the class upon instantiation: | ||
``` typescript | ||
const providedValueGenerator = new ProvidedValueGenerator(['up', 'left', 'right']); | ||
const firstValue = providedValueGenerator.nextValue(); // 'up' | ||
const secondValue = providedValueGenerator.nextValue(); // 'left' | ||
const thirdValue = providedValueGenerator.nextValue(); // 'right' | ||
const fourthValue = providedValueGenerator.nextValue(); // Error: 'Out of bounds!' | ||
``` | ||
## Example | ||
@@ -137,0 +150,0 @@ An example project using FactoryMate can be found here [FactoryMateConsumer](https://github.com/rwaskiewicz/factory-mate-consumer) |
Sorry, the diff of this file is not supported yet
13993
17
132
151
14