Skip to content

Commit

Permalink
Execute unit tests succesfully.
Browse files Browse the repository at this point in the history
Correctly configure unit tests to test for the siteId value.
  • Loading branch information
ryankelly-klaviyo committed Jun 3, 2024
1 parent b55fe93 commit af79586
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
"dependencies": {
"proxyquire": "^2.1.3"
}
}
}
2 changes: 2 additions & 0 deletions test/src/tests/unit/order-confirmation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const orderConfirmationEvent = proxyquire('int_klaviyo_core/cartridge/scripts/kl
'dw/catalog/ProductMgr': ProductMgr,
'*/cartridge/scripts/klaviyo/utils': {
KLImageSize: 'large',
siteId: Site.getCurrent().getID(),
captureProductOptions: basketStubs().pdctLineItems,
captureBonusProduct: basketStubs().bonusPdct,
captureProductBundles: basketStubs().bundlePdct,
Expand All @@ -72,6 +73,7 @@ describe('int_klaviyo_core/cartridge/scripts/klaviyo/eventData => orderConfirmat

it('should return event data for "Order Confirmation" event', () => {
const expectedResult = {
SiteID: 'KlaviyoSFRA',
'Order Total': '$9.99',
Tax: '$9.99',
Subtotal: '$9.99',
Expand Down
6 changes: 5 additions & 1 deletion test/src/tests/unit/started-checkout.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const expect = require('chai').expect
const path = require('path')
const sinon = require('sinon')
const proxyquire = require('proxyquire').noCallThru().noPreserveCache()
const Site = require('../mocks/dw.system.Site')
const StringUtils = require('../mocks/dw.util.StringUtils')
const Logger = require('../mocks/dw.system.Logger')
const URLUtils = require('../mocks/dw.web.URLUtils')
Expand All @@ -18,14 +19,16 @@ const basketManagerMock = new BasketMgr()
const currentBasket = basketManagerMock.getCurrentBasket()

const startedCheckoutEvent = proxyquire('int_klaviyo_core/cartridge/scripts/klaviyo/eventData/startedCheckout.js', {
'dw/system/Site': Site,
'dw/system/Logger': Logger,
'dw/web/URLUtils': URLUtils,
'dw/catalog/ProductMgr': ProductMgr,
'*/cartridge/scripts/klaviyo/utils': {
KLImageSize: 'large',
captureProductOptions: basketStubs().pdctLineItems,
captureBonusProduct: basketStubs().bonusPdct,
captureProductBundles: basketStubs().bundlePdct
captureProductBundles: basketStubs().bundlePdct,
siteId: Site.getCurrent().getID()
},
'dw/util/StringUtils': StringUtils,
'dw/value/Money': Money,
Expand Down Expand Up @@ -53,6 +56,7 @@ describe('int_klaviyo_core/cartridge/scripts/klaviyo/eventData => startedCheckou

it('should return the correct basket data for "Started Checkout" event', () => {
const expectedResult = {
SiteID: 'KlaviyoSFRA',
'Basket Gross Price': 99.99,
Categories: [
'Health'
Expand Down
3 changes: 2 additions & 1 deletion test/src/tests/unit/viewed-product.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ const viewedProductEvent = proxyquire('int_klaviyo_core/cartridge/scripts/klaviy
'dw/catalog/ProductMgr': ProductMgr,
'*/cartridge/scripts/klaviyo/utils': {
KLImageSize: 'large',
dedupeArray: dedupeArrayStub.withArgs(categories).returns(['Health'])
dedupeArray: dedupeArrayStub.withArgs(categories).returns(['Health']),
siteId: Site.getCurrent().getID(),
},
'*/cartridge/scripts/klaviyo/viewedProductHelpers.js': getProductPrices,
},
Expand Down

0 comments on commit af79586

Please sign in to comment.