Adjusted create method signature to better replicate TypeScript behavior
This commit is contained in:
parent
1674c05b66
commit
a7175c5ad4
|
@ -357,18 +357,11 @@ const completeOldSetupWizard = async () => {
|
|||
/**
|
||||
* Create simple product.
|
||||
*/
|
||||
const createSimpleProduct = async () => {
|
||||
try {
|
||||
const product = await factories.products.simple.create( {
|
||||
name: simpleProductName,
|
||||
regularPrice: '9.99'
|
||||
} );
|
||||
|
||||
return product.id;
|
||||
} catch ( error ) {
|
||||
console.log( 'Create Error ', error );
|
||||
}
|
||||
return null;
|
||||
const createSimpleProduct = () => {
|
||||
return factories.products.simple.create( {
|
||||
name: simpleProductName,
|
||||
regularPrice: '9.99'
|
||||
} ).then( product => product.id );
|
||||
} ;
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,7 +16,7 @@ export class AsyncFactory extends Factory {
|
|||
* @param {*} options The options to be used in the builder.
|
||||
* @return {Promise} Resolves to the created model.
|
||||
*/
|
||||
create( params, options ) {
|
||||
create( params = null, options = null ) {
|
||||
const model = this.build( params, options );
|
||||
return this.creator( model );
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ export class AsyncFactory extends Factory {
|
|||
* @param {*} options The options to be used in the builder.
|
||||
* @return {Promise} Resolves to the created models.
|
||||
*/
|
||||
createList( number, params, options ) {
|
||||
createList( number, params = null, options = null ) {
|
||||
const models = this.buildList( number, params, options );
|
||||
const promises = [];
|
||||
for ( const model of models ) {
|
||||
|
|
Loading…
Reference in New Issue