test-data-bot
Advanced tools
Comparing version 0.7.1 to 0.8.0
@@ -1,6 +0,10 @@ | ||
### 0.7.1 [20 Feb] 2019 | ||
### 0.8.0 - 04 March 2019 | ||
- Add `numberBetween` - [PR by @spilist](https://github.com/jackfranklin/test-data-bot/pull/43). | ||
### 0.7.1 - 20 Feb 2019 | ||
- Fix passing primitive values like `null` or `undefined` to a builder. (https://github.com/jackfranklin/test-data-bot/issues/39) | ||
### 0.7.0 [24 Jan] 2019 | ||
### 0.7.0 - 24 Jan 2019 | ||
@@ -10,11 +14,11 @@ - Fix a bug where you were unable to pass plain functions in as values to builders | ||
### 0.6.1 [01 Dec] 2018 | ||
### 0.6.1- 01 Dec 2018 | ||
- fix bug that meant overriding a boolean to always be `false` wouldn't happen (https://github.com/jackfranklin/test-data-bot/issues/6) | ||
### 0.6.0 [03 August] 2018 | ||
### 0.6.0- 03 August 2018 | ||
- rebuilt to enable fully nested builders | ||
### 0.5.0 [03 August] 2018 | ||
### 0.5.0- 03 August 2018 | ||
@@ -25,16 +29,16 @@ - add `arrayOf` | ||
### 0.4.0 [19 July] 2018 | ||
### 0.4.0- 19 July 2018 | ||
- add `oneOf` and `incrementingId` | ||
### 0.3.0 [13 June] 2018 | ||
### 0.3.0- 13 June 2018 | ||
- Fix `main` in `package.json` not pointing in the right place [PR by Kent C. Dodds](https://github.com/jackfranklin/test-data-bot/pull/1) | ||
- Fix `main` in `package.json` not pointing in the right place- PR by [Kent C. Dodds](https://github.com/jackfranklin/test-data-bot/pull/1) | ||
### 0.2.0 [12 June] 2018 | ||
### 0.2.0- 12 June 2018 | ||
- Added `perBuild` generator. | ||
### 0.1.0 [11 June] 2018 | ||
### 0.1.0- 11 June 2018 | ||
- First release! |
{ | ||
"name": "test-data-bot", | ||
"version": "0.7.1", | ||
"version": "0.8.0", | ||
"description": "Generate test data for your tests easily.", | ||
@@ -22,4 +22,4 @@ "engines": { | ||
"devDependencies": { | ||
"eslint": "5.14.1", | ||
"eslint-config-prettier": "4.0.0", | ||
"eslint": "5.15.0", | ||
"eslint-config-prettier": "4.1.0", | ||
"eslint-config-unobtrusive": "1.2.2", | ||
@@ -26,0 +26,0 @@ "eslint-plugin-jest": "22.3.0", |
@@ -39,2 +39,3 @@ # test-data-bot | ||
- A call to `bool`. This is a shortcut for `oneOf(true, false)` and will pick one of them at random. | ||
- A call to `numberBetween`. This takes two arguments as min/max, and generates a random integer between them. `numberBetween(0, 10)` is a shortcut for `fake(f => f.random.number({ min: 0, max: 10 })`. | ||
@@ -41,0 +42,0 @@ ## Mapping |
@@ -93,2 +93,4 @@ const Generator = require('./generator') | ||
const numberBetween = (min, max) => fake(f => f.random.number({ min, max })) | ||
module.exports = { | ||
@@ -103,2 +105,3 @@ build, | ||
bool, | ||
numberBetween, | ||
} |
@@ -10,2 +10,3 @@ const { | ||
arrayOf, | ||
numberBetween, | ||
} = require('./index') | ||
@@ -179,2 +180,21 @@ | ||
it('defines numberBetween to return a random integer between from min to max ', () => { | ||
const [min, max] = [-1, 1] | ||
const accountBuilder = build('Account').fields({ | ||
balance: numberBetween(min, max), | ||
}) | ||
const account = accountBuilder() | ||
expect(account.balance >= min).toBeTruthy() | ||
expect(account.balance <= max).toBeTruthy() | ||
}) | ||
it('lets a random number by numberBetween be overriden to be another number outside given range', () => { | ||
const [min, max] = [-1, 1] | ||
const accountBuilder = build('Account').fields({ | ||
balance: numberBetween(min, max), | ||
}) | ||
const account = accountBuilder({ balance: -100 }) | ||
expect(account.balance).toBe(-100) | ||
}) | ||
it('allows deeply nested fake data', () => { | ||
@@ -181,0 +201,0 @@ const itemBuilder = build('Item').fields({ |
Sorry, the diff of this file is not supported yet
175858
465
79