Adjusted create method signature to better replicate TypeScript behavior

This commit is contained in:
Christopher Allford 2020-09-21 13:44:45 -07:00
parent 1674c05b66
commit a7175c5ad4
2 changed files with 7 additions and 14 deletions

View File

@ -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 );
} ;
/**

View File

@ -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 ) {