Adds addLineItem to cart service; adds canCoverQuantity to product variant service
This commit is contained in:
1 parent
a912b81426
commit
8c515fa9d4
9 files changed
+493
-1
No files matched your search
@@ -11,6 +11,34 @@ export const carts = {
|
||||
discounts: [],
|
||||
customer_id: "",
|
||||
},
|
||||
cartWithLine: {
|
||||
_id: IdMap.getId("emptyCart"),
|
||||
title: "test",
|
||||
region: IdMap.getId("testRegion"),
|
||||
items: [
|
||||
{
|
||||
_id: IdMap.getId("existingLine"),
|
||||
title: "merge line",
|
||||
description: "This is a new line",
|
||||
thumbnail: "test-img-yeah.com/thumb",
|
||||
content: {
|
||||
unit_price: 123,
|
||||
variant: {
|
||||
_id: IdMap.getId("can-cover"),
|
||||
},
|
||||
product: {
|
||||
_id: IdMap.getId("product"),
|
||||
},
|
||||
quantity: 1,
|
||||
},
|
||||
quantity: 10,
|
||||
},
|
||||
],
|
||||
shippingAddress: {},
|
||||
billingAddress: {},
|
||||
discounts: [],
|
||||
customer_id: "",
|
||||
},
|
||||
}
|
||||
|
||||
export const CartModelMock = {
|
||||
@@ -23,6 +51,9 @@ export const CartModelMock = {
|
||||
if (query._id === IdMap.getId("emptyCart")) {
|
||||
return Promise.resolve(carts.emptyCart)
|
||||
}
|
||||
if (query._id === IdMap.getId("cartWithLine")) {
|
||||
return Promise.resolve(carts.cartWithLine)
|
||||
}
|
||||
return Promise.resolve(undefined)
|
||||
}),
|
||||
}
|
||||
@@ -28,6 +28,33 @@ export const ProductVariantModelMock = {
|
||||
if (query._id === IdMap.getId("failId")) {
|
||||
return Promise.reject(new Error("test error"))
|
||||
}
|
||||
if (query._id === IdMap.getId("inventory-test")) {
|
||||
return Promise.resolve({
|
||||
_id: IdMap.getId("inventory-test"),
|
||||
title: "inventory",
|
||||
inventory_quantity: 10,
|
||||
allow_backorder: false,
|
||||
manage_inventory: true,
|
||||
})
|
||||
}
|
||||
if (query._id === IdMap.getId("no-inventory-test")) {
|
||||
return Promise.resolve({
|
||||
_id: IdMap.getId("no-inventory-test"),
|
||||
title: "inventory",
|
||||
inventory_quantity: 0,
|
||||
allow_backorder: false,
|
||||
manage_inventory: false,
|
||||
})
|
||||
}
|
||||
if (query._id === IdMap.getId("backorder-test")) {
|
||||
return Promise.resolve({
|
||||
_id: IdMap.getId("backorder-test"),
|
||||
title: "inventory",
|
||||
inventory_quantity: 5,
|
||||
allow_backorder: true,
|
||||
manage_inventory: true,
|
||||
})
|
||||
}
|
||||
return Promise.resolve(undefined)
|
||||
}),
|
||||
}
|
||||
@@ -15,8 +15,11 @@ class ProductVariantModel extends BaseModel {
|
||||
prices: { type: [MoneyAmountSchema], default: [], required: true },
|
||||
options: { type: [OptionValueSchema], default: [] },
|
||||
image: { type: String, default: "" },
|
||||
metadata: { type: mongoose.Schema.Types.Mixed, default: {} },
|
||||
published: { type: Boolean, default: false },
|
||||
inventory_quantity: { type: Number, default: 0 },
|
||||
allow_backorder: { type: Boolean, default: false },
|
||||
manage_inventory: { type: Boolean, default: true },
|
||||
metadata: { type: mongoose.Schema.Types.Mixed, default: {} },
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ export default new mongoose.Schema({
|
||||
// [
|
||||
// {
|
||||
// unit_price: (MoneyAmount),
|
||||
// quantity: (Number),
|
||||
// variant: (ProductVariantSchema),
|
||||
// product: (ProductSchema)
|
||||
// }
|
||||
|
||||
Reference in new issue
Block a user