From b469286764f95a08767679b641f72297a3be0bf9 Mon Sep 17 00:00:00 2001 From: bartsimp Date: Thu, 16 Dec 2021 13:08:42 +0100 Subject: [PATCH] fix(iows): accept product code in dot notation (#77) --- source/lib/iows2.js | 2 +- source/lib/iows2.test.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/source/lib/iows2.js b/source/lib/iows2.js index 88028bb3..37fcb1d7 100644 --- a/source/lib/iows2.js +++ b/source/lib/iows2.js @@ -169,7 +169,7 @@ class IOWS2 { `Expected first argument productId to be a string, instead ${typeof productId} given. (5492aeea)` ); buCode = String(buCode).trim(); - productId = String(productId).trim(); + productId = String(productId).trim().replace(/\./g, ''); if (!productType) { productType = PRODUCT_TYPE.ART; diff --git a/source/lib/iows2.test.js b/source/lib/iows2.test.js index 5b30391b..8ec043df 100644 --- a/source/lib/iows2.test.js +++ b/source/lib/iows2.test.js @@ -106,6 +106,17 @@ describe('IOWS2', () => { }); }); + it('accept product code in dot notation', () => { + const scope = nock(iows.baseUrl) + .get((uri) => { + expect(uri).to.match(/\/999$/); + return true; + }) + .reply(200, bodyData); + return iows.getStoreProductAvailability('123', '9.9.9') + .then(() => scope.isDone()); + }); + it('detects the productType form the productCode when it starts with an "s"', () => { const scope = nock(iows.baseUrl) .get((uri) => {