Adds use of injected decorators in all services (#122)
* hotfix(services): Use injected decorators in services * Fixes test
This commit is contained in:
committed by
GitHub
parent
ade0104c16
commit
371fd0c433
@@ -466,7 +466,7 @@ describe("OrderService", () => {
|
||||
expect(OrderModelMock.updateOne).toHaveBeenCalledWith(
|
||||
{ _id: IdMap.getId("test-order") },
|
||||
{
|
||||
$push: {
|
||||
$addToSet: {
|
||||
fulfillments: {
|
||||
$each: [
|
||||
{
|
||||
|
||||
@@ -246,7 +246,9 @@ class CartService extends BaseService {
|
||||
if (expandFields.includes("region")) {
|
||||
c.region = await this.regionService_.retrieve(cart.region_id)
|
||||
}
|
||||
return c
|
||||
|
||||
const final = await this.runDecorators_(c)
|
||||
return final
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -381,7 +381,8 @@ class CustomerService extends BaseService {
|
||||
)
|
||||
}
|
||||
|
||||
return decorated
|
||||
const final = await this.runDecorators_(decorated)
|
||||
return final
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -455,7 +455,8 @@ class DiscountService extends BaseService {
|
||||
)
|
||||
}
|
||||
|
||||
return decorated
|
||||
const final = await this.runDecorators_(decorated)
|
||||
return final
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -985,7 +985,8 @@ class OrderService extends BaseService {
|
||||
}
|
||||
})
|
||||
|
||||
return o
|
||||
const final = await this.runDecorators_(o)
|
||||
return final
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -493,7 +493,8 @@ class ProductVariantService extends BaseService {
|
||||
async decorate(variant, fields, expandFields = []) {
|
||||
const requiredFields = ["_id", "metadata"]
|
||||
const decorated = _.pick(variant, fields.concat(requiredFields))
|
||||
return decorated
|
||||
const final = await this.runDecorators_(decorated)
|
||||
return final
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -716,7 +716,8 @@ class ProductService extends BaseService {
|
||||
if (expandFields.includes("variants")) {
|
||||
decorated.variants = await this.retrieveVariants(product._id)
|
||||
}
|
||||
return decorated
|
||||
const final = await this.runDecorators_(decorated)
|
||||
return final
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -367,7 +367,8 @@ class RegionService extends BaseService {
|
||||
async decorate(region, fields, expandFields = []) {
|
||||
const requiredFields = ["_id", "metadata"]
|
||||
const decorated = _.pick(region, fields.concat(requiredFields))
|
||||
return decorated
|
||||
const final = await this.runDecorators_(decorated)
|
||||
return final
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -405,7 +405,8 @@ class ShippingOptionService extends BaseService {
|
||||
const requiredFields = ["_id", "metadata"]
|
||||
let decorated = _.pick(shippingOption, fields.concat(requiredFields))
|
||||
|
||||
return decorated
|
||||
const final = await this.runDecorators_(decorated)
|
||||
return final
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -376,7 +376,8 @@ class ShippingProfileService extends BaseService {
|
||||
)
|
||||
}
|
||||
|
||||
return decorated
|
||||
const final = await this.runDecorators_(decorated)
|
||||
return final
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -278,7 +278,8 @@ class UserService extends BaseService {
|
||||
async decorate(user, fields, expandFields = []) {
|
||||
const requiredFields = ["_id", "metadata"]
|
||||
const decorated = _.pick(user, fields.concat(requiredFields))
|
||||
return decorated
|
||||
const final = await this.runDecorators_(decorated)
|
||||
return final
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user