LearningSalesForceCommerceC.../storefront-reference-architecture/test/mocks/dw/order/ShippingMgr.js
2021-12-21 10:57:31 -08:00

74 lines
2.1 KiB
JavaScript

var ArrayList = require('../../../mocks/dw.util.Collection');
var defaultShippingMethod =
{
description: 'Order received within 7-10 business days',
displayName: 'Ground',
ID: '001',
custom: {
estimatedArrivalTime: '7-10 Business Days'
}
};
function createShipmentShippingModel() {
return {
applicableShippingMethods: new ArrayList([
{
description: 'Order received within 7-10 business days',
displayName: 'Ground',
ID: '001',
custom: {
estimatedArrivalTime: '7-10 Business Days'
}
},
{
description: 'Order received in 2 business days',
displayName: '2-Day Express',
ID: '002',
shippingCost: '$0.00',
custom: {
estimatedArrivalTime: '2 Business Days'
}
}
]),
getApplicableShippingMethods: function () {
return new ArrayList([
{
description: 'Order received within 7-10 business days',
displayName: 'Ground',
ID: '001',
custom: {
estimatedArrivalTime: '7-10 Business Days'
}
},
{
description: 'Order received in 2 business days',
displayName: '2-Day Express',
ID: '002',
shippingCost: '$0.00',
custom: {
estimatedArrivalTime: '2 Business Days'
}
}
]);
},
getShippingCost: function () {
return {
amount: {
valueOrNull: 7.99
}
};
}
};
}
module.exports = {
getDefaultShippingMethod: function () {
return defaultShippingMethod;
},
getShipmentShippingModel: function (shipment) {
return createShipmentShippingModel(shipment);
}
};