Adds SFRA 6.0
This commit is contained in:
17
storefront-reference-architecture/test/mocks/.eslintrc.json
Normal file
17
storefront-reference-architecture/test/mocks/.eslintrc.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"parserOptions": {
|
||||
"sourceType": "module"
|
||||
},
|
||||
"env": {
|
||||
"mocha": true,
|
||||
"es6": true
|
||||
},
|
||||
"rules": {
|
||||
"max-len": "off",
|
||||
"no-use-before-define": "off",
|
||||
"require-jsdoc": "off"
|
||||
},
|
||||
"globals": {
|
||||
"browser": true
|
||||
}
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function (array) {
|
||||
var items = [];
|
||||
if (array) {
|
||||
items = array;
|
||||
}
|
||||
|
||||
this.add = function (item) {
|
||||
items.push(item);
|
||||
};
|
||||
|
||||
this.iterator = function () {
|
||||
var i = 0;
|
||||
return {
|
||||
hasNext: function () {
|
||||
return i < items.length;
|
||||
},
|
||||
next: function () {
|
||||
return items[i++];
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
this.getLength = function () {
|
||||
return items.length;
|
||||
};
|
||||
|
||||
this.length = this.getLength();
|
||||
|
||||
this.toArray = function () {
|
||||
return items;
|
||||
};
|
||||
|
||||
this.addAll = function (collection) {
|
||||
items = items.concat(collection.toArray());
|
||||
};
|
||||
|
||||
this.contains = function (item) {
|
||||
return array.indexOf(item) >= 0;
|
||||
};
|
||||
|
||||
this.map = function () {
|
||||
var args = Array.from(arguments);
|
||||
var list = args[0];
|
||||
var callback = args[1];
|
||||
if (list && Object.prototype.hasOwnProperty.call(list, 'toArray')) {
|
||||
list = list.toArray();
|
||||
}
|
||||
return list ? list.map(callback) : [];
|
||||
};
|
||||
|
||||
this.get = function (index) {
|
||||
return items[index];
|
||||
};
|
||||
};
|
@@ -0,0 +1,13 @@
|
||||
'use strict';
|
||||
|
||||
function Money(isAvailable) {
|
||||
return {
|
||||
available: isAvailable,
|
||||
value: '10.99',
|
||||
getDecimalValue: function () { return '10.99'; },
|
||||
getCurrencyCode: function () { return 'USD'; },
|
||||
subtract: function () { return new Money(isAvailable); }
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = Money;
|
@@ -0,0 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
|
||||
module.exports = {
|
||||
http: function (id) {
|
||||
return id;
|
||||
},
|
||||
staticURL: function () {
|
||||
return 'some url';
|
||||
},
|
||||
url: function () {
|
||||
return 'someUrl';
|
||||
}
|
||||
};
|
@@ -0,0 +1,98 @@
|
||||
'use strict';
|
||||
|
||||
var productInventoryMgr = {
|
||||
getInventoryList: function (inventoryListId) {
|
||||
var inventoryListId0001 = {
|
||||
getRecord: function (productID) {
|
||||
var product000001 = {
|
||||
ATS: { value: 10 }
|
||||
};
|
||||
|
||||
var product000002 = {
|
||||
ATS: { value: 3 }
|
||||
};
|
||||
|
||||
var product000003 = {
|
||||
ATS: { value: 5 }
|
||||
};
|
||||
|
||||
if (productID === '000001') {
|
||||
return product000001;
|
||||
} else if (productID === '000002') {
|
||||
return product000002;
|
||||
} else if (productID === '000003') {
|
||||
return product000003;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
var inventoryListId0002 = {
|
||||
getRecord: function (productID) {
|
||||
var product000001 = {
|
||||
ATS: { value: 0 }
|
||||
};
|
||||
|
||||
var product000002 = {
|
||||
ATS: { value: 8 }
|
||||
};
|
||||
|
||||
var product000003 = {
|
||||
ATS: { value: 10 }
|
||||
};
|
||||
|
||||
if (productID === '000001') {
|
||||
return product000001;
|
||||
} else if (productID === '000002') {
|
||||
return product000002;
|
||||
} else if (productID === '000003') {
|
||||
return product000003;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
var inventoryListId0003 = {
|
||||
getRecord: function (productID) {
|
||||
var product000001 = {
|
||||
ATS: { value: 10 }
|
||||
};
|
||||
|
||||
var product000002 = {
|
||||
ATS: { value: 15 }
|
||||
};
|
||||
|
||||
var product000003 = {
|
||||
ATS: { value: 8 }
|
||||
};
|
||||
|
||||
if (productID === '000001') {
|
||||
return product000001;
|
||||
} else if (productID === '000002') {
|
||||
return product000002;
|
||||
} else if (productID === '000003') {
|
||||
return product000003;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
if (inventoryListId === 'inventoryListId0001') {
|
||||
return inventoryListId0001;
|
||||
} else if (inventoryListId === 'inventoryListId0002') {
|
||||
return inventoryListId0002;
|
||||
} else if (inventoryListId === 'inventoryListId0003') {
|
||||
return inventoryListId0003;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
module.exports = {
|
||||
getInventoryList: productInventoryMgr.getInventoryList
|
||||
};
|
@@ -0,0 +1,60 @@
|
||||
'use strict';
|
||||
|
||||
var storeMgr = {
|
||||
searchStoresByPostalCode: function () {
|
||||
return {
|
||||
keySet: function () {
|
||||
return [{
|
||||
ID: 'Any ID',
|
||||
name: 'Downtown TV Shop',
|
||||
address1: '333 Washington St',
|
||||
address2: '',
|
||||
city: 'Boston',
|
||||
postalCode: '01803',
|
||||
phone: '333-333-3333',
|
||||
stateCode: 'MA',
|
||||
countryCode: {
|
||||
value: 'us'
|
||||
},
|
||||
latitude: 42.5273334,
|
||||
longitude: -71.13758250000001,
|
||||
storeHours: {
|
||||
markup: 'Mon - Sat: 10am - 9pm'
|
||||
}
|
||||
}];
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
searchStoresByCoordinates: function () {
|
||||
return {
|
||||
keySet: function () {
|
||||
return [{
|
||||
ID: 'Any ID',
|
||||
name: 'Downtown TV Shop',
|
||||
address1: '333 Washington St',
|
||||
address2: '',
|
||||
city: 'Boston',
|
||||
postalCode: '01803',
|
||||
phone: '333-333-3333',
|
||||
stateCode: 'MA',
|
||||
countryCode: {
|
||||
value: 'us'
|
||||
},
|
||||
latitude: 42.5273334,
|
||||
longitude: -71.13758250000001,
|
||||
storeHours: {
|
||||
markup: 'Mon - Sat: 10am - 9pm'
|
||||
}
|
||||
}];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
module.exports = {
|
||||
searchStoresByPostalCode: storeMgr.searchStoresByPostalCode,
|
||||
searchStoresByCoordinates: storeMgr.searchStoresByCoordinates
|
||||
};
|
@@ -0,0 +1,35 @@
|
||||
|
||||
function getCurrentBasket() {
|
||||
return {
|
||||
defaultShipment: {
|
||||
shippingAddress: {
|
||||
firstName: 'Amanda',
|
||||
lastName: 'Jones',
|
||||
address1: '65 May Lane',
|
||||
address2: '',
|
||||
city: 'Allston',
|
||||
postalCode: '02135',
|
||||
countryCode: { value: 'us' },
|
||||
phone: '617-555-1234',
|
||||
stateCode: 'MA',
|
||||
|
||||
setFirstName: function (firstNameInput) { this.firstName = firstNameInput; },
|
||||
setLastName: function (lastNameInput) { this.lastName = lastNameInput; },
|
||||
setAddress1: function (address1Input) { this.address1 = address1Input; },
|
||||
setAddress2: function (address2Input) { this.address2 = address2Input; },
|
||||
setCity: function (cityInput) { this.city = cityInput; },
|
||||
setPostalCode: function (postalCodeInput) { this.postalCode = postalCodeInput; },
|
||||
setStateCode: function (stateCodeInput) { this.stateCode = stateCodeInput; },
|
||||
setCountryCode: function (countryCodeInput) { this.countryCode.value = countryCodeInput; },
|
||||
setPhone: function (phoneInput) { this.phone = phoneInput; }
|
||||
}
|
||||
},
|
||||
totalGrossPrice: {
|
||||
value: 250.00
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getCurrentBasket: getCurrentBasket
|
||||
};
|
@@ -0,0 +1,73 @@
|
||||
|
||||
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);
|
||||
}
|
||||
};
|
@@ -0,0 +1,60 @@
|
||||
'use strict';
|
||||
|
||||
var path = require('path');
|
||||
var properties = require('properties-parser');
|
||||
const locale = 'x_default';
|
||||
|
||||
function msg(key, bundleName, defaultValue) {
|
||||
let bundlePath;
|
||||
let props;
|
||||
const resourceDirPath = './cartridges/app_storefront_base/cartridge/templates/resources/';
|
||||
if (!key) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (bundleName) {
|
||||
if (locale !== 'x_default') {
|
||||
bundlePath = path.resolve(resourceDirPath + bundleName + '_' + locale + '.properties');
|
||||
try {
|
||||
props = properties.read(bundlePath);
|
||||
if (props[key]) {
|
||||
return props[key];
|
||||
}
|
||||
} catch (e) {
|
||||
// continue
|
||||
}
|
||||
}
|
||||
bundlePath = path.resolve(resourceDirPath + bundleName + '.properties');
|
||||
try {
|
||||
props = properties.read(bundlePath);
|
||||
if (props[key]) {
|
||||
return props[key];
|
||||
}
|
||||
} catch (e) {
|
||||
// continue
|
||||
}
|
||||
}
|
||||
return defaultValue || key;
|
||||
}
|
||||
|
||||
function msgf() {
|
||||
// pass through to msg if there are no extra format arguments
|
||||
if (arguments.length < 4) {
|
||||
return msg.apply(null, arguments);
|
||||
}
|
||||
let args = Array.prototype.slice.call(arguments);
|
||||
let value = msg.apply(null, args.slice(0, 3));
|
||||
return value.replace(/{(\d)}/g, function (match, p) {
|
||||
let position = Number(p);
|
||||
if (args[position + 3]) {
|
||||
return args[position + 3];
|
||||
// if no arguments found, return the original placeholder
|
||||
}
|
||||
return match;
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
msg: msg,
|
||||
msgf: msgf,
|
||||
locale: locale
|
||||
};
|
@@ -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();
|
@@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
var proxyquire = require('proxyquire').noCallThru().noPreserveCache();
|
||||
|
||||
function proxyModel() {
|
||||
return proxyquire('../../../cartridges/app_storefront_base/cartridge/models/address', {});
|
||||
}
|
||||
|
||||
module.exports = proxyModel();
|
@@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
var proxyquire = require('proxyquire').noCallThru().noPreserveCache();
|
||||
|
||||
function proxyModel() {
|
||||
return proxyquire('../../../cartridges/app_storefront_base/cartridge/models/billing', {});
|
||||
}
|
||||
|
||||
module.exports = proxyModel();
|
83
storefront-reference-architecture/test/mocks/models/cart.js
Normal file
83
storefront-reference-architecture/test/mocks/models/cart.js
Normal file
@@ -0,0 +1,83 @@
|
||||
'use strict';
|
||||
|
||||
var proxyquire = require('proxyquire').noCallThru().noPreserveCache();
|
||||
|
||||
var TotalsModel = require('./totals');
|
||||
var ProductLineItemsModel = require('./productLineItems');
|
||||
|
||||
var ShippingHelpers = require('../helpers/shippingHelpers');
|
||||
|
||||
var URLUtils = require('../dw.web.URLUtils');
|
||||
var ArrayList = require('../dw.util.Collection');
|
||||
var Money = require('../dw.value.Money');
|
||||
|
||||
function proxyModel() {
|
||||
return proxyquire('../../../cartridges/app_storefront_base/cartridge/models/cart', {
|
||||
'*/cartridge/scripts/util/collections': {},
|
||||
'dw/campaign/PromotionMgr': {
|
||||
getDiscounts: function () {
|
||||
return {
|
||||
getApproachingOrderDiscounts: function () {
|
||||
return new ArrayList([{
|
||||
getDistanceFromConditionThreshold: function () {
|
||||
return new Money();
|
||||
},
|
||||
getDiscount: function () {
|
||||
return {
|
||||
getPromotion: function () {
|
||||
return {
|
||||
getCalloutMsg: function () {
|
||||
return 'someString';
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
}]);
|
||||
},
|
||||
getApproachingShippingDiscounts: function () {
|
||||
return new ArrayList([{
|
||||
getDistanceFromConditionThreshold: function () {
|
||||
return new Money();
|
||||
},
|
||||
getDiscount: function () {
|
||||
return {
|
||||
getPromotion: function () {
|
||||
return {
|
||||
getCalloutMsg: function () {
|
||||
return 'someString';
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
}]);
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
'*/cartridge/models/totals': TotalsModel,
|
||||
'*/cartridge/models/productLineItems': ProductLineItemsModel,
|
||||
'*/cartridge/scripts/checkout/shippingHelpers': ShippingHelpers,
|
||||
'*/cartridge/scripts/helpers/hooks': function () {
|
||||
return { error: false, message: 'some message' };
|
||||
},
|
||||
'*/cartridge/scripts/hooks/validateBasket': function () {},
|
||||
'dw/web/URLUtils': URLUtils,
|
||||
'dw/util/StringUtils': {
|
||||
formatMoney: function () {
|
||||
return 'formatted money';
|
||||
}
|
||||
},
|
||||
'dw/web/Resource': {
|
||||
msg: function () {
|
||||
return 'someString';
|
||||
},
|
||||
msgf: function () {
|
||||
return 'someString';
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = proxyModel();
|
63
storefront-reference-architecture/test/mocks/models/order.js
Normal file
63
storefront-reference-architecture/test/mocks/models/order.js
Normal file
@@ -0,0 +1,63 @@
|
||||
'use strict';
|
||||
|
||||
var proxyquire = require('proxyquire').noCallThru().noPreserveCache();
|
||||
|
||||
var AddressModel = require('./address');
|
||||
var BillingModel = require('./billing');
|
||||
var ShippingModel = require('./shipping');
|
||||
var PaymentModel = require('./payment');
|
||||
var TotalsModel = require('./totals');
|
||||
var ProductLineItemsModel = require('./productLineItems');
|
||||
|
||||
function proxyModel() {
|
||||
return proxyquire('../../../cartridges/app_storefront_base/cartridge/models/order', {
|
||||
'dw/web/URLUtils': {
|
||||
},
|
||||
'dw/order/PaymentMgr': {
|
||||
},
|
||||
'dw/util/StringUtils': {
|
||||
formatMoney: function () {
|
||||
return 'formatted money';
|
||||
}
|
||||
},
|
||||
'dw/web/Resource': {
|
||||
msg: function () {
|
||||
return 'someString';
|
||||
},
|
||||
msgf: function () {
|
||||
return 'someString';
|
||||
}
|
||||
},
|
||||
'dw/system/HookMgr': function () {},
|
||||
'*/cartridge/models/address': AddressModel,
|
||||
'*/cartridge/models/billing': BillingModel,
|
||||
'*/cartridge/models/shipping': ShippingModel,
|
||||
'*/cartridge/models/payment': PaymentModel,
|
||||
'*/cartridge/models/totals': TotalsModel,
|
||||
'*/cartridge/models/productLineItems': ProductLineItemsModel,
|
||||
'*/cartridge/scripts/checkout/shippingHelpers': {
|
||||
getShippingModels: function () {
|
||||
return [{ shippingAddress: {
|
||||
firstName: 'someString',
|
||||
lastName: null
|
||||
}
|
||||
}];
|
||||
}
|
||||
},
|
||||
'*/cartridge/scripts/checkout/checkoutHelpers': {
|
||||
isPickUpInStore: function () {
|
||||
return false;
|
||||
},
|
||||
ensureValidShipments: function () {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
'dw/util/Locale': {
|
||||
getLocale: function () {
|
||||
return 'US';
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = proxyModel();
|
@@ -0,0 +1,52 @@
|
||||
'use strict';
|
||||
|
||||
var proxyquire = require('proxyquire').noCallThru().noPreserveCache();
|
||||
var collections = require('../util/collections');
|
||||
|
||||
function proxyModel() {
|
||||
return proxyquire('../../../cartridges/app_storefront_base/cartridge/models/payment', {
|
||||
'*/cartridge/scripts/util/collections': collections,
|
||||
'dw/order/PaymentMgr': {
|
||||
getApplicablePaymentMethods: function () {
|
||||
return [
|
||||
{
|
||||
ID: 'GIFT_CERTIFICATE',
|
||||
name: 'Gift Certificate'
|
||||
},
|
||||
{
|
||||
ID: 'CREDIT_CARD',
|
||||
name: 'Credit Card'
|
||||
}
|
||||
];
|
||||
},
|
||||
getPaymentMethod: function () {
|
||||
return {
|
||||
getApplicablePaymentCards: function () {
|
||||
return [
|
||||
{
|
||||
cardType: 'Visa',
|
||||
name: 'Visa',
|
||||
UUID: 'some UUID'
|
||||
},
|
||||
{
|
||||
cardType: 'Amex',
|
||||
name: 'American Express',
|
||||
UUID: 'some UUID'
|
||||
},
|
||||
{
|
||||
cardType: 'Discover',
|
||||
name: 'Discover'
|
||||
}
|
||||
];
|
||||
}
|
||||
};
|
||||
},
|
||||
getApplicablePaymentCards: function () {
|
||||
return ['applicable payment cards'];
|
||||
}
|
||||
},
|
||||
'dw/order/PaymentInstrument': {}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = proxyModel();
|
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
var proxyquire = require('proxyquire').noCallThru().noPreserveCache();
|
||||
var collections = require('../util/collections');
|
||||
|
||||
function proxyModel() {
|
||||
return proxyquire('../../../cartridges/app_storefront_base/cartridge/models/productLineItems', {
|
||||
'*/cartridge/scripts/util/collections': collections,
|
||||
'*/cartridge/scripts/factories/product': {
|
||||
get: function () {
|
||||
return { bonusProducts: null, bonusProductLineItemUUID: null };
|
||||
}
|
||||
},
|
||||
'dw/web/URLUtils': {
|
||||
staticURL: function () {
|
||||
return '/images/noimagelarge.png';
|
||||
}
|
||||
},
|
||||
'dw/web/Resource': {
|
||||
msgf: function (param1) {
|
||||
return param1;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = proxyModel();
|
@@ -0,0 +1,58 @@
|
||||
'use strict';
|
||||
|
||||
var proxyquire = require('proxyquire').noCallThru().noPreserveCache();
|
||||
|
||||
var collections = require('../util/collections');
|
||||
|
||||
var AddressModel = require('./address');
|
||||
var ProductLineItemsModel = require('./productLineItems');
|
||||
var ShippingMethodModel = require('./shippingMethod');
|
||||
|
||||
var ShippingMgr = require('../dw/order/ShippingMgr');
|
||||
|
||||
var shippingHelpers = {
|
||||
getApplicableShippingMethods: function (shipment, address) {
|
||||
var shippingMethods;
|
||||
if (shipment === null && address === null) {
|
||||
shippingMethods = null;
|
||||
} else {
|
||||
shippingMethods = [
|
||||
{
|
||||
description: 'Order received within 7-10 business days',
|
||||
displayName: 'Ground',
|
||||
ID: '001',
|
||||
shippingCost: '$0.00',
|
||||
estimatedArrivalTime: '7-10 Business Days'
|
||||
},
|
||||
{
|
||||
description: 'Order received in 2 business days',
|
||||
displayName: '2-Day Express',
|
||||
ID: '002',
|
||||
shippingCost: '$9.99',
|
||||
estimatedArrivalTime: '2 Business Days'
|
||||
}
|
||||
];
|
||||
}
|
||||
return shippingMethods;
|
||||
}
|
||||
};
|
||||
|
||||
function proxyModel() {
|
||||
return proxyquire('../../../cartridges/app_storefront_base/cartridge/models/shipping', {
|
||||
'*/cartridge/models/address': AddressModel,
|
||||
'*/cartridge/models/productLineItems': ProductLineItemsModel,
|
||||
'*/cartridge/models/shipping/shippingMethod': ShippingMethodModel,
|
||||
'*/cartridge/scripts/checkout/shippingHelpers': shippingHelpers,
|
||||
'*/cartridge/scripts/util/collections': collections,
|
||||
'*/cartridge/scripts/util/formatting': {},
|
||||
'dw/util/StringUtils': {
|
||||
formatMoney: function () {
|
||||
return 'formattedMoney';
|
||||
}
|
||||
},
|
||||
'dw/value/Money': require('../dw.value.Money'),
|
||||
'dw/order/ShippingMgr': ShippingMgr
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = proxyModel();
|
@@ -0,0 +1,85 @@
|
||||
'use strict';
|
||||
|
||||
var proxyquire = require('proxyquire').noCallThru().noPreserveCache();
|
||||
|
||||
var defaultShippingMethod =
|
||||
{
|
||||
description: 'Order received within 7-10 business days',
|
||||
displayName: 'Ground',
|
||||
ID: '001',
|
||||
custom: {
|
||||
estimatedArrivalTime: '7-10 Business Days'
|
||||
}
|
||||
};
|
||||
|
||||
function createShipmentShippingModel() {
|
||||
return {
|
||||
applicableShippingMethods: [
|
||||
{
|
||||
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 [
|
||||
{
|
||||
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
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function proxyModel() {
|
||||
return proxyquire('../../../cartridges/app_storefront_base/cartridge/models/shipping/shippingMethod', {
|
||||
'*/cartridge/scripts/util/formatting': {
|
||||
formatCurrency: function () {
|
||||
return '$0.00';
|
||||
}
|
||||
},
|
||||
'dw/order/ShippingMgr': {
|
||||
getDefaultShippingMethod: function () {
|
||||
return defaultShippingMethod;
|
||||
},
|
||||
getShipmentShippingModel: function (shipment) {
|
||||
return createShipmentShippingModel(shipment);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = proxyModel();
|
@@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
var proxyquire = require('proxyquire').noCallThru().noPreserveCache();
|
||||
|
||||
function proxyModel() {
|
||||
return proxyquire('../../../cartridges/app_storefront_base/cartridge/models/store', {});
|
||||
}
|
||||
|
||||
module.exports = proxyModel();
|
@@ -0,0 +1,34 @@
|
||||
'use strict';
|
||||
|
||||
var proxyquire = require('proxyquire').noCallThru().noPreserveCache();
|
||||
|
||||
var Money = require('../dw.value.Money');
|
||||
|
||||
function proxyModel() {
|
||||
return proxyquire('../../../cartridges/app_storefront_base/cartridge/models/totals', {
|
||||
'dw/util/StringUtils': {
|
||||
formatMoney: function () {
|
||||
return 'formatted money';
|
||||
}
|
||||
},
|
||||
'dw/value/Money': Money,
|
||||
'dw/util/Template': function () {
|
||||
return {
|
||||
render: function () {
|
||||
return { text: 'someString' };
|
||||
}
|
||||
};
|
||||
},
|
||||
'dw/util/HashMap': function () {
|
||||
return {
|
||||
result: {},
|
||||
put: function (key, context) {
|
||||
this.result[key] = context;
|
||||
}
|
||||
};
|
||||
},
|
||||
'*/cartridge/scripts/util/collections': require('../util/collections')
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = proxyModel();
|
@@ -0,0 +1,16 @@
|
||||
'use strict';
|
||||
|
||||
function Response() {
|
||||
this.base = {};
|
||||
}
|
||||
|
||||
Response.prototype = {
|
||||
render: function render() {},
|
||||
json: function json() {},
|
||||
redirect: function redirect(url) {
|
||||
this.redirectUrl = url;
|
||||
},
|
||||
setViewData: function () {}
|
||||
};
|
||||
|
||||
module.exports = Response;
|
@@ -0,0 +1,97 @@
|
||||
'use strict';
|
||||
|
||||
var proxyquire = require('proxyquire').noCallThru().noPreserveCache();
|
||||
var sinon = require('sinon');
|
||||
|
||||
var stubBase = sinon.stub();
|
||||
var stubPrice = sinon.stub();
|
||||
var stubImages = sinon.stub();
|
||||
var stubAvailability = sinon.stub();
|
||||
var stubDescription = sinon.stub();
|
||||
var stubSearchPrice = sinon.stub();
|
||||
var stubPromotions = sinon.stub();
|
||||
var stubQuantity = sinon.stub();
|
||||
var stubQuantitySelector = sinon.stub();
|
||||
var stubRatings = sinon.stub();
|
||||
var stubSizeChart = sinon.stub();
|
||||
var stubVariationAttributes = sinon.stub();
|
||||
var stubSearchVariationAttributes = sinon.stub();
|
||||
var stubAttributes = sinon.stub();
|
||||
var stubOptions = sinon.stub();
|
||||
var stubCurrentUrl = sinon.stub();
|
||||
var stubReadyToOrder = sinon.stub();
|
||||
var stubOnline = sinon.stub();
|
||||
var stubSetReadyToOrder = sinon.stub();
|
||||
var stubBundleReadyToOrder = sinon.stub();
|
||||
var stubSetIndividualProducts = sinon.stub();
|
||||
var stubSetProductsCollection = sinon.stub();
|
||||
var stubBundledProducts = sinon.stub();
|
||||
var stubBonusUnitPrice = sinon.stub();
|
||||
var stubRaw = sinon.stub();
|
||||
var stubPageMetaData = sinon.stub();
|
||||
var stubTemplate = sinon.stub();
|
||||
|
||||
function proxyModel() {
|
||||
return {
|
||||
mocks: proxyquire('../../cartridges/app_storefront_base/cartridge/models/product/decorators/index', {
|
||||
'*/cartridge/models/product/decorators/base': stubBase,
|
||||
'*/cartridge/models/product/decorators/availability': stubAvailability,
|
||||
'*/cartridge/models/product/decorators/description': stubDescription,
|
||||
'*/cartridge/models/product/decorators/images': stubImages,
|
||||
'*/cartridge/models/product/decorators/price': stubPrice,
|
||||
'*/cartridge/models/product/decorators/searchPrice': stubSearchPrice,
|
||||
'*/cartridge/models/product/decorators/promotions': stubPromotions,
|
||||
'*/cartridge/models/product/decorators/quantity': stubQuantity,
|
||||
'*/cartridge/models/product/decorators/quantitySelector': stubQuantitySelector,
|
||||
'*/cartridge/models/product/decorators/ratings': stubRatings,
|
||||
'*/cartridge/models/product/decorators/sizeChart': stubSizeChart,
|
||||
'*/cartridge/models/product/decorators/variationAttributes': stubVariationAttributes,
|
||||
'*/cartridge/models/product/decorators/searchVariationAttributes': stubSearchVariationAttributes,
|
||||
'*/cartridge/models/product/decorators/attributes': stubAttributes,
|
||||
'*/cartridge/models/product/decorators/options': stubOptions,
|
||||
'*/cartridge/models/product/decorators/currentUrl': stubCurrentUrl,
|
||||
'*/cartridge/models/product/decorators/readyToOrder': stubReadyToOrder,
|
||||
'*/cartridge/models/product/decorators/online': stubOnline,
|
||||
'*/cartridge/models/product/decorators/setReadyToOrder': stubSetReadyToOrder,
|
||||
'*/cartridge/models/product/decorators/bundleReadyToOrder': stubBundleReadyToOrder,
|
||||
'*/cartridge/models/product/decorators/setIndividualProducts': stubSetIndividualProducts,
|
||||
'*/cartridge/models/product/decorators/setProductsCollection': stubSetProductsCollection,
|
||||
'*/cartridge/models/product/decorators/bundledProducts': stubBundledProducts,
|
||||
'*/cartridge/models/product/decorators/bonusUnitPrice': stubBonusUnitPrice,
|
||||
'*/cartridge/models/product/decorators/raw': stubRaw,
|
||||
'*/cartridge/models/product/decorators/pageMetaData': stubPageMetaData,
|
||||
'*/cartridge/models/product/decorators/template': stubTemplate
|
||||
}),
|
||||
stubs: {
|
||||
stubBase: stubBase,
|
||||
stubPrice: stubPrice,
|
||||
stubImages: stubImages,
|
||||
stubAvailability: stubAvailability,
|
||||
stubDescription: stubDescription,
|
||||
stubSearchPrice: stubSearchPrice,
|
||||
stubPromotions: stubPromotions,
|
||||
stubQuantity: stubQuantity,
|
||||
stubQuantitySelector: stubQuantitySelector,
|
||||
stubRatings: stubRatings,
|
||||
stubSizeChart: stubSizeChart,
|
||||
stubVariationAttributes: stubVariationAttributes,
|
||||
stubSearchVariationAttributes: stubSearchVariationAttributes,
|
||||
stubAttributes: stubAttributes,
|
||||
stubOptions: stubOptions,
|
||||
stubCurrentUrl: stubCurrentUrl,
|
||||
stubReadyToOrder: stubReadyToOrder,
|
||||
stubOnline: stubOnline,
|
||||
stubSetReadyToOrder: stubSetReadyToOrder,
|
||||
stubBundleReadyToOrder: stubBundleReadyToOrder,
|
||||
stubSetIndividualProducts: stubSetIndividualProducts,
|
||||
stubSetProductsCollection: stubSetProductsCollection,
|
||||
stubBundledProducts: stubBundledProducts,
|
||||
stubBonusUnitPrice: stubBonusUnitPrice,
|
||||
stubRaw: stubRaw,
|
||||
stubPageMetaData: stubPageMetaData,
|
||||
stubTemplate: stubTemplate
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = proxyModel();
|
@@ -0,0 +1,64 @@
|
||||
'use strict';
|
||||
|
||||
var proxyquire = require('proxyquire').noCallThru().noPreserveCache();
|
||||
var sinon = require('sinon');
|
||||
|
||||
var stubGift = sinon.stub();
|
||||
var stubBonusProductLineItem = sinon.stub();
|
||||
var stubAppliedPromotions = sinon.stub();
|
||||
var stubRenderedPromotions = sinon.stub();
|
||||
var stubUuid = sinon.stub();
|
||||
var stubOrderable = sinon.stub();
|
||||
var stubShipment = sinon.stub();
|
||||
var stubPriceTotal = sinon.stub();
|
||||
var stubQuantityOptions = sinon.stub();
|
||||
var stubOptions = sinon.stub();
|
||||
var stubQuantity = sinon.stub();
|
||||
var stubBundledProductLineItems = sinon.stub();
|
||||
var stubBonusProductLineItemUUID = sinon.stub();
|
||||
var stubDiscountBonusLineItems = sinon.stub();
|
||||
var stubBonusUnitPrice = sinon.stub();
|
||||
var stubPreOrderUUID = sinon.stub();
|
||||
|
||||
function proxyModel() {
|
||||
return {
|
||||
mocks: proxyquire('../../cartridges/app_storefront_base/cartridge/models/productLineItem/decorators/index', {
|
||||
'*/cartridge/models/productLineItem/decorators/gift': stubGift,
|
||||
'*/cartridge/models/productLineItem/decorators/bonusProductLineItem': stubBonusProductLineItem,
|
||||
'*/cartridge/models/productLineItem/decorators/appliedPromotions': stubAppliedPromotions,
|
||||
'*/cartridge/models/productLineItem/decorators/renderedPromotions': stubRenderedPromotions,
|
||||
'*/cartridge/models/productLineItem/decorators/uuid': stubUuid,
|
||||
'*/cartridge/models/productLineItem/decorators/orderable': stubOrderable,
|
||||
'*/cartridge/models/productLineItem/decorators/shipment': stubShipment,
|
||||
'*/cartridge/models/productLineItem/decorators/priceTotal': stubPriceTotal,
|
||||
'*/cartridge/models/productLineItem/decorators/quantityOptions': stubQuantityOptions,
|
||||
'*/cartridge/models/productLineItem/decorators/options': stubOptions,
|
||||
'*/cartridge/models/productLineItem/decorators/quantity': stubQuantity,
|
||||
'*/cartridge/models/productLineItem/decorators/bundledProductLineItems': stubBundledProductLineItems,
|
||||
'*/cartridge/models/productLineItem/decorators/bonusProductLineItemUUID': stubBonusProductLineItemUUID,
|
||||
'*/cartridge/models/productLineItem/decorators/discountBonusLineItems': stubDiscountBonusLineItems,
|
||||
'*/cartridge/models/productLineItem/decorators/bonusUnitPrice': stubBonusUnitPrice,
|
||||
'*/cartridge/models/productLineItem/decorators/preOrderUUID': stubPreOrderUUID
|
||||
}),
|
||||
stubs: {
|
||||
stubGift: stubGift,
|
||||
stubBonusProductLineItem: stubBonusProductLineItem,
|
||||
stubAppliedPromotions: stubAppliedPromotions,
|
||||
stubRenderedPromotions: stubRenderedPromotions,
|
||||
stubUuid: stubUuid,
|
||||
stubOrderable: stubOrderable,
|
||||
stubShipment: stubShipment,
|
||||
stubPriceTotal: stubPriceTotal,
|
||||
stubQuantityOptions: stubQuantityOptions,
|
||||
stubOptions: stubOptions,
|
||||
stubQuantity: stubQuantity,
|
||||
stubBundledProductLineItems: stubBundledProductLineItems,
|
||||
stubDiscountBonusLineItems: stubDiscountBonusLineItems,
|
||||
stubBonusProductLineItemUUID: stubBonusProductLineItemUUID,
|
||||
stubBonusUnitPrice: stubBonusUnitPrice,
|
||||
stubPreOrderUUID: stubPreOrderUUID
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = proxyModel();
|
@@ -0,0 +1,48 @@
|
||||
'use strict';
|
||||
|
||||
function map() {
|
||||
var args = Array.from(arguments);
|
||||
var list = args[0];
|
||||
var callback = args[1];
|
||||
if (list && Object.prototype.hasOwnProperty.call(list, 'toArray')) {
|
||||
list = list.toArray();
|
||||
}
|
||||
return list ? list.map(callback) : [];
|
||||
}
|
||||
|
||||
function find() {
|
||||
var args = Array.from(arguments);
|
||||
var list = args[0];
|
||||
var callback = args[1];
|
||||
if (list && Object.prototype.hasOwnProperty.call(list, 'toArray')) {
|
||||
list = list.toArray();
|
||||
}
|
||||
return list ? list.find(callback) : null;
|
||||
}
|
||||
|
||||
function forEach() {
|
||||
var args = Array.from(arguments);
|
||||
var list = args[0];
|
||||
var callback = args[1];
|
||||
if (list && Object.prototype.hasOwnProperty.call(list, 'toArray')) {
|
||||
list = list.toArray();
|
||||
}
|
||||
return list ? list.forEach(callback) : null;
|
||||
}
|
||||
|
||||
function every() {
|
||||
var args = Array.from(arguments);
|
||||
var list = args[0];
|
||||
var callback = args[1];
|
||||
if (list && Object.prototype.hasOwnProperty.call(list, 'toArray')) {
|
||||
list = list.toArray();
|
||||
}
|
||||
return list ? list.every(callback) : null;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
find: find,
|
||||
forEach: forEach,
|
||||
map: map,
|
||||
every: every
|
||||
};
|
Reference in New Issue
Block a user