Merge master
This commit is contained in:
commit
48310ff384
29 files changed
+1024
-24
No files matched your search
@@ -0,0 +1,193 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports["default"] = exports.CartServiceMock = exports.carts = void 0;
|
||||
|
||||
var _medusaTestUtils = require("medusa-test-utils");
|
||||
|
||||
var carts = {
|
||||
emptyCart: {
|
||||
_id: _medusaTestUtils.IdMap.getId("emptyCart"),
|
||||
items: [],
|
||||
region_id: _medusaTestUtils.IdMap.getId("testRegion"),
|
||||
shipping_options: [{
|
||||
_id: _medusaTestUtils.IdMap.getId("freeShipping"),
|
||||
profile_id: "default_profile",
|
||||
data: {
|
||||
some_data: "yes"
|
||||
}
|
||||
}]
|
||||
},
|
||||
frCart: {
|
||||
_id: _medusaTestUtils.IdMap.getId("fr-cart"),
|
||||
email: "lebron@james.com",
|
||||
title: "test",
|
||||
region_id: _medusaTestUtils.IdMap.getId("region-france"),
|
||||
items: [{
|
||||
_id: _medusaTestUtils.IdMap.getId("line"),
|
||||
title: "merge line",
|
||||
description: "This is a new line",
|
||||
thumbnail: "test-img-yeah.com/thumb",
|
||||
content: [{
|
||||
unit_price: 8,
|
||||
variant: {
|
||||
_id: _medusaTestUtils.IdMap.getId("eur-8-us-10")
|
||||
},
|
||||
product: {
|
||||
_id: _medusaTestUtils.IdMap.getId("product")
|
||||
},
|
||||
quantity: 1
|
||||
}, {
|
||||
unit_price: 10,
|
||||
variant: {
|
||||
_id: _medusaTestUtils.IdMap.getId("eur-10-us-12")
|
||||
},
|
||||
product: {
|
||||
_id: _medusaTestUtils.IdMap.getId("product")
|
||||
},
|
||||
quantity: 1
|
||||
}],
|
||||
quantity: 10
|
||||
}, {
|
||||
_id: _medusaTestUtils.IdMap.getId("existingLine"),
|
||||
title: "merge line",
|
||||
description: "This is a new line",
|
||||
thumbnail: "test-img-yeah.com/thumb",
|
||||
content: {
|
||||
unit_price: 10,
|
||||
variant: {
|
||||
_id: _medusaTestUtils.IdMap.getId("eur-10-us-12")
|
||||
},
|
||||
product: {
|
||||
_id: _medusaTestUtils.IdMap.getId("product")
|
||||
},
|
||||
quantity: 1
|
||||
},
|
||||
quantity: 10
|
||||
}],
|
||||
shipping_methods: [{
|
||||
_id: _medusaTestUtils.IdMap.getId("freeShipping"),
|
||||
profile_id: "default_profile"
|
||||
}],
|
||||
shipping_options: [{
|
||||
_id: _medusaTestUtils.IdMap.getId("freeShipping"),
|
||||
profile_id: "default_profile"
|
||||
}],
|
||||
payment_sessions: [{
|
||||
provider_id: "stripe",
|
||||
data: {
|
||||
id: "pi_123456789",
|
||||
customer: _medusaTestUtils.IdMap.getId("not-lebron")
|
||||
}
|
||||
}],
|
||||
payment_method: {
|
||||
provider_id: "stripe",
|
||||
data: {
|
||||
id: "pi_123456789",
|
||||
customer: _medusaTestUtils.IdMap.getId("not-lebron")
|
||||
}
|
||||
},
|
||||
shipping_address: {},
|
||||
billing_address: {},
|
||||
discounts: [],
|
||||
customer_id: _medusaTestUtils.IdMap.getId("lebron")
|
||||
},
|
||||
frCartNoStripeCustomer: {
|
||||
_id: _medusaTestUtils.IdMap.getId("fr-cart-no-customer"),
|
||||
title: "test",
|
||||
region_id: _medusaTestUtils.IdMap.getId("region-france"),
|
||||
items: [{
|
||||
_id: _medusaTestUtils.IdMap.getId("line"),
|
||||
title: "merge line",
|
||||
description: "This is a new line",
|
||||
thumbnail: "test-img-yeah.com/thumb",
|
||||
content: [{
|
||||
unit_price: 8,
|
||||
variant: {
|
||||
_id: _medusaTestUtils.IdMap.getId("eur-8-us-10")
|
||||
},
|
||||
product: {
|
||||
_id: _medusaTestUtils.IdMap.getId("product")
|
||||
},
|
||||
quantity: 1
|
||||
}, {
|
||||
unit_price: 10,
|
||||
variant: {
|
||||
_id: _medusaTestUtils.IdMap.getId("eur-10-us-12")
|
||||
},
|
||||
product: {
|
||||
_id: _medusaTestUtils.IdMap.getId("product")
|
||||
},
|
||||
quantity: 1
|
||||
}],
|
||||
quantity: 10
|
||||
}, {
|
||||
_id: _medusaTestUtils.IdMap.getId("existingLine"),
|
||||
title: "merge line",
|
||||
description: "This is a new line",
|
||||
thumbnail: "test-img-yeah.com/thumb",
|
||||
content: {
|
||||
unit_price: 10,
|
||||
variant: {
|
||||
_id: _medusaTestUtils.IdMap.getId("eur-10-us-12")
|
||||
},
|
||||
product: {
|
||||
_id: _medusaTestUtils.IdMap.getId("product")
|
||||
},
|
||||
quantity: 1
|
||||
},
|
||||
quantity: 10
|
||||
}],
|
||||
shipping_methods: [{
|
||||
_id: _medusaTestUtils.IdMap.getId("freeShipping"),
|
||||
profile_id: "default_profile"
|
||||
}],
|
||||
shipping_options: [{
|
||||
_id: _medusaTestUtils.IdMap.getId("freeShipping"),
|
||||
profile_id: "default_profile"
|
||||
}],
|
||||
payment_sessions: [{
|
||||
provider_id: "stripe",
|
||||
data: {
|
||||
id: "pi_123456789",
|
||||
customer: _medusaTestUtils.IdMap.getId("not-lebron")
|
||||
}
|
||||
}],
|
||||
payment_method: {
|
||||
provider_id: "stripe",
|
||||
data: {
|
||||
id: "pi_123456789",
|
||||
customer: _medusaTestUtils.IdMap.getId("not-lebron")
|
||||
}
|
||||
},
|
||||
shipping_address: {},
|
||||
billing_address: {},
|
||||
discounts: [],
|
||||
customer_id: _medusaTestUtils.IdMap.getId("vvd")
|
||||
}
|
||||
};
|
||||
exports.carts = carts;
|
||||
var CartServiceMock = {
|
||||
retrieve: jest.fn().mockImplementation(function (cartId) {
|
||||
if (cartId === _medusaTestUtils.IdMap.getId("fr-cart")) {
|
||||
return Promise.resolve(carts.frCart);
|
||||
}
|
||||
|
||||
if (cartId === _medusaTestUtils.IdMap.getId("emptyCart")) {
|
||||
return Promise.resolve(carts.emptyCart);
|
||||
}
|
||||
|
||||
return Promise.resolve(undefined);
|
||||
}),
|
||||
updatePaymentSession: jest.fn().mockImplementation(function (cartId, stripe, paymentIntent) {
|
||||
return Promise.resolve();
|
||||
})
|
||||
};
|
||||
exports.CartServiceMock = CartServiceMock;
|
||||
var mock = jest.fn().mockImplementation(function () {
|
||||
return CartServiceMock;
|
||||
});
|
||||
var _default = mock;
|
||||
exports["default"] = _default;
|
||||
@@ -0,0 +1,45 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports["default"] = exports.CustomerServiceMock = void 0;
|
||||
|
||||
var _medusaTestUtils = require("medusa-test-utils");
|
||||
|
||||
var CustomerServiceMock = {
|
||||
retrieve: jest.fn().mockImplementation(function (id) {
|
||||
if (id === _medusaTestUtils.IdMap.getId("lebron")) {
|
||||
return Promise.resolve({
|
||||
_id: _medusaTestUtils.IdMap.getId("lebron"),
|
||||
first_name: "LeBron",
|
||||
last_name: "James",
|
||||
email: "lebron@james.com",
|
||||
password_hash: "1234",
|
||||
metadata: {
|
||||
stripe_id: "cus_123456789_new"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (id === _medusaTestUtils.IdMap.getId("vvd")) {
|
||||
return Promise.resolve({
|
||||
_id: _medusaTestUtils.IdMap.getId("vvd"),
|
||||
first_name: "Virgil",
|
||||
last_name: "Van Dijk",
|
||||
email: "virg@vvd.com",
|
||||
password_hash: "1234",
|
||||
metadata: {}
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.resolve(undefined);
|
||||
}),
|
||||
setMetadata: jest.fn().mockReturnValue(Promise.resolve())
|
||||
};
|
||||
exports.CustomerServiceMock = CustomerServiceMock;
|
||||
var mock = jest.fn().mockImplementation(function () {
|
||||
return CustomerServiceMock;
|
||||
});
|
||||
var _default = mock;
|
||||
exports["default"] = _default;
|
||||
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports["default"] = exports.EventBusServiceMock = void 0;
|
||||
var EventBusServiceMock = {
|
||||
emit: jest.fn(),
|
||||
subscribe: jest.fn()
|
||||
};
|
||||
exports.EventBusServiceMock = EventBusServiceMock;
|
||||
var mock = jest.fn().mockImplementation(function () {
|
||||
return EventBusServiceMock;
|
||||
});
|
||||
var _default = mock;
|
||||
exports["default"] = _default;
|
||||
@@ -0,0 +1,96 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports["default"] = exports.StripeMock = void 0;
|
||||
var StripeMock = {
|
||||
customers: {
|
||||
create: jest.fn().mockImplementation(function (data) {
|
||||
if (data.email === "virg@vvd.com") {
|
||||
return Promise.resolve({
|
||||
id: "cus_vvd",
|
||||
email: "virg@vvd.com"
|
||||
});
|
||||
}
|
||||
|
||||
if (data.email === "lebron@james.com") {
|
||||
return Promise.resolve({
|
||||
id: "cus_lebron",
|
||||
email: "lebron@james.com"
|
||||
});
|
||||
}
|
||||
})
|
||||
},
|
||||
paymentIntents: {
|
||||
create: jest.fn().mockImplementation(function (data) {
|
||||
if (data.customer === "cus_123456789_new") {
|
||||
return Promise.resolve({
|
||||
id: "pi_lebron",
|
||||
amount: 100,
|
||||
customer: "cus_123456789_new"
|
||||
});
|
||||
}
|
||||
|
||||
if (data.customer === "cus_lebron") {
|
||||
return Promise.resolve({
|
||||
id: "pi_lebron",
|
||||
amount: 100,
|
||||
customer: "cus_lebron"
|
||||
});
|
||||
}
|
||||
}),
|
||||
retrieve: jest.fn().mockImplementation(function (data) {
|
||||
return Promise.resolve({
|
||||
id: "pi_lebron",
|
||||
customer: "cus_lebron"
|
||||
});
|
||||
}),
|
||||
update: jest.fn().mockImplementation(function (pi, data) {
|
||||
if (data.customer === "cus_lebron_2") {
|
||||
return Promise.resolve({
|
||||
id: "pi_lebron",
|
||||
customer: "cus_lebron_2",
|
||||
amount: 1000
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.resolve({
|
||||
id: "pi_lebron",
|
||||
customer: "cus_lebron",
|
||||
amount: 1000
|
||||
});
|
||||
}),
|
||||
capture: jest.fn().mockImplementation(function (data) {
|
||||
return Promise.resolve({
|
||||
id: "pi_lebron",
|
||||
customer: "cus_lebron",
|
||||
amount: 1000,
|
||||
status: "succeeded"
|
||||
});
|
||||
}),
|
||||
cancel: jest.fn().mockImplementation(function (data) {
|
||||
return Promise.resolve({
|
||||
id: "pi_lebron",
|
||||
customer: "cus_lebron",
|
||||
status: "cancelled"
|
||||
});
|
||||
})
|
||||
},
|
||||
refunds: {
|
||||
create: jest.fn().mockImplementation(function (data) {
|
||||
return Promise.resolve({
|
||||
id: "re_123",
|
||||
payment_intent: "pi_lebron",
|
||||
amount: 1000,
|
||||
status: "succeeded"
|
||||
});
|
||||
})
|
||||
}
|
||||
};
|
||||
exports.StripeMock = StripeMock;
|
||||
var stripe = jest.fn(function () {
|
||||
return StripeMock;
|
||||
});
|
||||
var _default = stripe;
|
||||
exports["default"] = _default;
|
||||
@@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports["default"] = exports.TotalsServiceMock = void 0;
|
||||
var TotalsServiceMock = {
|
||||
getTotal: jest.fn()
|
||||
};
|
||||
exports.TotalsServiceMock = TotalsServiceMock;
|
||||
var mock = jest.fn().mockImplementation(function () {
|
||||
return TotalsServiceMock;
|
||||
});
|
||||
var _default = mock;
|
||||
exports["default"] = _default;
|
||||
Reference in new issue
Block a user