Creates setRegion

This commit is contained in:
Sebastian Rindom committed 2020-02-05 16:20:04 +01:00
1 parent 2f2dd5eae3
commit 8fb5845874
5 files changed
+334 -16

No files matched your search

+102 -3
View File
@@ -4,7 +4,7 @@ export const carts = {
emptyCart: {
_id: IdMap.getId("emptyCart"),
title: "test",
region: IdMap.getId("testRegion"),
region_id: IdMap.getId("testRegion"),
items: [],
shippingAddress: {},
billingAddress: {},
@@ -12,9 +12,9 @@ export const carts = {
customer_id: "",
},
cartWithLine: {
_id: IdMap.getId("emptyCart"),
_id: IdMap.getId("cartWithLine"),
title: "test",
region: IdMap.getId("testRegion"),
region_id: IdMap.getId("testRegion"),
items: [
{
_id: IdMap.getId("existingLine"),
@@ -39,6 +39,99 @@ export const carts = {
discounts: [],
customer_id: "",
},
completeCart: {
_id: IdMap.getId("complete-cart"),
title: "test",
region_id: IdMap.getId("region-france"),
items: [],
payment_method: {
provider_id: "stripe",
data: {
yes: "sir",
},
},
shipping_method: {
provider_id: "gls",
data: {
yes: "sir",
},
},
shipping_address: {
first_name: "hi",
last_name: "you",
country_code: "DK",
city: "of lights",
address_1: "You bet street",
postal_code: "4242",
},
billing_address: {
first_name: "hi",
last_name: "you",
country_code: "DK",
city: "of lights",
address_1: "You bet street",
postal_code: "4242",
},
discounts: [],
customer_id: "",
},
frCart: {
_id: IdMap.getId("fr-cart"),
title: "test",
region_id: IdMap.getId("region-france"),
items: [
{
_id: IdMap.getId("line"),
title: "merge line",
description: "This is a new line",
thumbnail: "test-img-yeah.com/thumb",
content: [
{
unit_price: 8,
variant: {
_id: IdMap.getId("eur-8-us-10"),
},
product: {
_id: IdMap.getId("product"),
},
quantity: 1,
},
{
unit_price: 10,
variant: {
_id: IdMap.getId("eur-10-us-12"),
},
product: {
_id: IdMap.getId("product"),
},
quantity: 1,
},
],
quantity: 10,
},
{
_id: IdMap.getId("existingLine"),
title: "merge line",
description: "This is a new line",
thumbnail: "test-img-yeah.com/thumb",
content: {
unit_price: 10,
variant: {
_id: IdMap.getId("eur-10-us-12"),
},
product: {
_id: IdMap.getId("product"),
},
quantity: 1,
},
quantity: 10,
},
],
shippingAddress: {},
billingAddress: {},
discounts: [],
customer_id: "",
},
}
export const CartModelMock = {
@@ -54,6 +147,12 @@ export const CartModelMock = {
if (query._id === IdMap.getId("cartWithLine")) {
return Promise.resolve(carts.cartWithLine)
}
if (query._id === IdMap.getId("fr-cart")) {
return Promise.resolve(carts.frCart)
}
if (query._id === IdMap.getId("complete-cart")) {
return Promise.resolve(carts.completeCart)
}
return Promise.resolve(undefined)
}),
}
+1 -1
View File
@@ -17,7 +17,7 @@ class CartModel extends BaseModel {
billing_address: { type: AddressSchema },
shipping_address: { type: AddressSchema },
items: { type: [LineItemSchema], default: [] },
region: { type: String, required: true },
region_id: { type: String },
discounts: { type: [String], default: [] },
customer_id: { type: String },
payment_method: { type: PaymentMethodSchema },