Adds SFRA 6.0
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
'use strict';
|
||||
|
||||
|
||||
var proxyquire = require('proxyquire').noCallThru().noPreserveCache();
|
||||
|
||||
var collections = require('../util/collections');
|
||||
var addressModel = require('../models/address');
|
||||
var orderModel = require('../models/order');
|
||||
|
||||
var renderTemplateHelper = require('./renderTemplateHelper');
|
||||
var shippingHelpers = require('./shippingHelpers');
|
||||
var basketMgr = require('../dw/order/BasketMgr');
|
||||
|
||||
|
||||
var server = {
|
||||
forms: {
|
||||
getForm: function (formName) {
|
||||
return {
|
||||
formName: formName,
|
||||
clear: function () {}
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var transaction = {
|
||||
wrap: function (callBack) {
|
||||
return callBack.call();
|
||||
},
|
||||
begin: function () {},
|
||||
commit: function () {}
|
||||
};
|
||||
|
||||
var hookMgr = {
|
||||
callHook: function () {}
|
||||
};
|
||||
|
||||
var resource = {
|
||||
msg: function (param1) {
|
||||
return param1;
|
||||
}
|
||||
};
|
||||
|
||||
var status = {
|
||||
OK: 0,
|
||||
ERROR: 1
|
||||
};
|
||||
|
||||
var orderMgr = {
|
||||
createOrder: function () {
|
||||
return { order: 'new order' };
|
||||
},
|
||||
placeOrder: function () {
|
||||
return status.OK;
|
||||
},
|
||||
failOrder: function () {
|
||||
return { order: 'failed order' };
|
||||
}
|
||||
};
|
||||
|
||||
var order = {
|
||||
CONFIRMATION_STATUS_NOTCONFIRMED: 'ONFIRMATION_STATUS_NOTCONFIRMED',
|
||||
CONFIRMATION_STATUS_CONFIRMED: 'CONFIRMATION_STATUS_CONFIRMED',
|
||||
EXPORT_STATUS_READY: 'order export status is ready'
|
||||
};
|
||||
|
||||
function proxyModel() {
|
||||
return proxyquire('../../../cartridges/app_storefront_base/cartridge/scripts/checkout/checkoutHelpers', {
|
||||
'server': server,
|
||||
'*/cartridge/scripts/util/collections': collections,
|
||||
'*/cartridge/scripts/helpers/basketCalculationHelpers': { calculateTotals: function () {} },
|
||||
|
||||
'dw/order/BasketMgr': basketMgr,
|
||||
'dw/util/HashMap': {},
|
||||
'dw/system/HookMgr': hookMgr,
|
||||
'dw/net/Mail': {},
|
||||
'dw/order/OrderMgr': orderMgr,
|
||||
'dw/order/PaymentInstrument': {},
|
||||
'dw/order/PaymentMgr': {},
|
||||
'dw/order/Order': order,
|
||||
'dw/system/Status': status,
|
||||
'dw/web/Resource': resource,
|
||||
'dw/system/Site': {},
|
||||
'dw/util/Template': {},
|
||||
'dw/system/Transaction': transaction,
|
||||
|
||||
'*/cartridge/models/address': addressModel,
|
||||
'*/cartridge/models/order': orderModel,
|
||||
|
||||
'*/cartridge/scripts/renderTemplateHelper': renderTemplateHelper,
|
||||
'*/cartridge/scripts/checkout/shippingHelpers': shippingHelpers,
|
||||
'*/cartridge/scripts/formErrors': require('../../../cartridges/app_storefront_base/cartridge/scripts/formErrors')
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = proxyModel();
|
@@ -0,0 +1,32 @@
|
||||
'use strict';
|
||||
|
||||
// mocking ~/cartridge/scripts/renderTemplateHelper
|
||||
|
||||
var proxyquire = require('proxyquire').noCallThru().noPreserveCache();
|
||||
var sinon = require('sinon');
|
||||
var templateStub = sinon.stub();
|
||||
|
||||
templateStub.returns({
|
||||
render: function () {
|
||||
return { text: 'rendered html' };
|
||||
}
|
||||
});
|
||||
|
||||
function proxyModel() {
|
||||
return proxyquire('../../../cartridges/app_storefront_base/cartridge/scripts/renderTemplateHelper', {
|
||||
'dw/util/Template': templateStub,
|
||||
'dw/util/HashMap': function () {
|
||||
return {
|
||||
result: {},
|
||||
put: function (key, context) {
|
||||
this.result[key] = context;
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
templateStub: templateStub,
|
||||
proxyModel: proxyModel
|
||||
};
|
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
var proxyquire = require('proxyquire').noCallThru().noPreserveCache();
|
||||
|
||||
var collections = require('../util/collections');
|
||||
var ShippingModel = require('../models/shipping');
|
||||
var ShippingMethodModel = require('../models/shippingMethod');
|
||||
var ShippingMgr = require('../dw/order/ShippingMgr');
|
||||
|
||||
function proxyModel() {
|
||||
return proxyquire('../../../cartridges/app_storefront_base/cartridge/scripts/checkout/shippingHelpers', {
|
||||
'*/cartridge/scripts/util/collections': collections,
|
||||
'*/cartridge/models/shipping': ShippingModel,
|
||||
'*/cartridge/models/shipping/shippingMethod': ShippingMethodModel,
|
||||
'dw/order/ShippingMgr': ShippingMgr
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = proxyModel();
|
@@ -0,0 +1,91 @@
|
||||
'use strict';
|
||||
|
||||
var proxyquire = require('proxyquire').noCallThru().noPreserveCache();
|
||||
var sinon = require('sinon');
|
||||
var templateStub = sinon.stub();
|
||||
var StoreModel = require('../models/store');
|
||||
|
||||
var StoresModel = proxyquire('../../../cartridges/app_storefront_base/cartridge/models/stores', {
|
||||
'*/cartridge/models/store': StoreModel,
|
||||
'dw/util/HashMap': function () {
|
||||
return {
|
||||
result: {},
|
||||
put: function (key, context) {
|
||||
this.result[key] = context;
|
||||
}
|
||||
};
|
||||
},
|
||||
'dw/value/Money': function () {},
|
||||
'dw/util/Template': function () {
|
||||
return {
|
||||
render: function () {
|
||||
return { text: 'someString' };
|
||||
}
|
||||
};
|
||||
},
|
||||
'*/cartridge/scripts/renderTemplateHelper': {
|
||||
getRenderedHtml: function () { return 'someString'; }
|
||||
},
|
||||
|
||||
'*/cartridge/scripts/helpers/storeHelpers': {
|
||||
createStoresResultsHtml: function () {
|
||||
return 'someString';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var storeMgr = require('../dw/catalog/StoreMgr');
|
||||
|
||||
var site = {
|
||||
getCurrent: function () {
|
||||
return {
|
||||
getCustomPreferenceValue: function () {
|
||||
return 'SOME_API_KEY';
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
var urlUtils = {
|
||||
url: function (endPointName) {
|
||||
return {
|
||||
toString: function () {
|
||||
return 'path-to-endpoint/' + endPointName;
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
var productInventoryMgr = require('../dw/catalog/ProductInventoryMgr');
|
||||
|
||||
var hashMap = function () {
|
||||
return {
|
||||
result: {},
|
||||
put: function (key, context) {
|
||||
this.result[key] = context;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
templateStub.returns({
|
||||
render: function () {
|
||||
return { text: 'rendered html' };
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function proxyModel() {
|
||||
return proxyquire('../../../cartridges/app_storefront_base/cartridge/scripts/helpers/storeHelpers', {
|
||||
'*/cartridge/models/store': StoreModel,
|
||||
'*/cartridge/models/stores': StoresModel,
|
||||
'dw/catalog/StoreMgr': storeMgr,
|
||||
'dw/system/Site': site,
|
||||
'dw/web/URLUtils': urlUtils,
|
||||
'dw/catalog/ProductInventoryMgr': productInventoryMgr,
|
||||
'dw/util/HashMap': hashMap,
|
||||
'dw/util/Template': templateStub
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = proxyModel();
|
Reference in New Issue
Block a user