factory-girl
Advanced tools
Comparing version 5.0.0-beta.1 to 5.0.0
@@ -296,6 +296,11 @@ import _slicedToArray from 'babel-runtime/helpers/slicedToArray'; | ||
case 0: | ||
_context5.next = 2; | ||
if (Array.isArray(num)) { | ||
buildOptionsArray = attrsArray; | ||
attrsArray = num; | ||
num = attrsArray.length; | ||
} | ||
_context5.next = 3; | ||
return this.buildMany(adapter, num, attrsArray, buildOptionsArray); | ||
case 2: | ||
case 3: | ||
models = _context5.sent; | ||
@@ -311,3 +316,3 @@ savedModels = models.map(function (model) { | ||
case 5: | ||
case 6: | ||
case 'end': | ||
@@ -314,0 +319,0 @@ return _context5.stop(); |
11
index.js
@@ -302,6 +302,11 @@ 'use strict'; | ||
case 0: | ||
_context5.next = 2; | ||
if (Array.isArray(num)) { | ||
buildOptionsArray = attrsArray; | ||
attrsArray = num; | ||
num = attrsArray.length; | ||
} | ||
_context5.next = 3; | ||
return this.buildMany(adapter, num, attrsArray, buildOptionsArray); | ||
case 2: | ||
case 3: | ||
models = _context5.sent; | ||
@@ -317,3 +322,3 @@ savedModels = models.map(function (model) { | ||
case 5: | ||
case 6: | ||
case 'end': | ||
@@ -320,0 +325,0 @@ return _context5.stop(); |
@@ -302,6 +302,11 @@ (function (global, factory) { | ||
case 0: | ||
_context5.next = 2; | ||
if (Array.isArray(num)) { | ||
buildOptionsArray = attrsArray; | ||
attrsArray = num; | ||
num = attrsArray.length; | ||
} | ||
_context5.next = 3; | ||
return this.buildMany(adapter, num, attrsArray, buildOptionsArray); | ||
case 2: | ||
case 3: | ||
models = _context5.sent; | ||
@@ -317,3 +322,3 @@ savedModels = models.map(function (model) { | ||
case 5: | ||
case 6: | ||
case 'end': | ||
@@ -320,0 +325,0 @@ return _context5.stop(); |
@@ -9,3 +9,3 @@ { | ||
], | ||
"version": "5.0.0-beta.1", | ||
"version": "5.0.0", | ||
"keywords": [ | ||
@@ -12,0 +12,0 @@ "factory", |
@@ -142,2 +142,19 @@ # factory-girl | ||
### Extending Factories | ||
You can extend a factory using `#extend`: | ||
```js | ||
factory.define('user', User, { username: 'Bob', expired: false }); | ||
factory.extend('user', 'expiredUser', { expired: true }); | ||
factory.build('expiredUser').then(user => { | ||
console.log(user); // => User { username: 'Bob', expired: true }); | ||
}); | ||
``` | ||
### `#extend(parent, name, initializer, options = {})` | ||
The `#extend` method takes the same options as `#define` except you | ||
can provide a different `Model` using `options.model`. | ||
## Using Factories | ||
@@ -206,2 +223,4 @@ | ||
### Factory#createMany(name, num, attrs, buildOptions = {}) | ||
The createMany version creates an array of model instances. | ||
@@ -216,4 +235,10 @@ | ||
Similar to `Factory#attrs` and `Factory#build`, you can pass `attrs` to override and | ||
`buildOptions`. | ||
`buildOptions`. If you pass an array of `attrs` then each element of the array will be | ||
used as the attrs for a each model created. | ||
### Factory#createMany(name, attrs, buildOptions = {}) | ||
If you can pass an array of `attrs` then you can omit `num` and the length of the array | ||
will be used. | ||
### Factory#cleanUp | ||
@@ -231,4 +256,5 @@ | ||
```javascript | ||
const factory = require('factory-girl').factory; | ||
const adapter = new factoryGirl.MongooseAdapter(); | ||
const FactoryGirl = require('factory-girl'); | ||
const factory = FactoryGirl.factory; | ||
const adapter = new FactoryGirl.MongooseAdapter(); | ||
@@ -235,0 +261,0 @@ // use the mongoose adapter as the default adapter |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
741011
14981
1
312