@shopgate/pwa-core 7.8.0 → 7.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{hasSGJavaScriptBridge}from"../../helpers";import{defaultClientInformation}from"../../helpers/version";import AppCommand from"./index";// Mocks for the logger.
1
+ import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{hasSGJavaScriptBridge}from"../../helpers";import{defaultClientInformation}from"../../helpers/version";import AppCommand from"./index";jest.unmock("./index.js");// Mocks for the logger.
2
2
  var mockedLoggerError=jest.fn();var mockedLoggerWarn=jest.fn();jest.mock("../../helpers",function(){return{logger:{error:function error(){mockedLoggerError.apply(void 0,arguments);},warn:function warn(){mockedLoggerWarn.apply(void 0,arguments);},log:function log(){}},hasSGJavaScriptBridge:jest.fn().mockReturnValue(false),useBrowserConnector:function useBrowserConnector(){return false;}};});var mockedLogGroup=jest.fn();// eslint-disable-next-line extra-rules/potential-point-free
3
3
  jest.mock("../../helpers/logGroup",function(){return function logGroup(){mockedLogGroup.apply(void 0,arguments);};});// Mock of the DevServer bridge.
4
4
  var mockedBridgeDispatch=jest.fn();jest.mock("../DevServerBridge",function(){return function(){return{dispatchCommandsForVersion:mockedBridgeDispatch};};});// Mock of the client information web storage.
@@ -1,2 +1,2 @@
1
- import PipelineRequest,{DEFAULT_VERSION,DEFAULT_RETRIES,DEFAULT_MAX_RETRIES,DEFAULT_INPUT,DEFAULT_TIMEOUT,DEFAULT_MAX_TIMEOUT,DEFAULT_PROCESSED,DEFAULT_HANDLE_ERROR}from'.';import*as processTypes from"../../constants/ProcessTypes";import*as errorHandleTypes from"../../constants/ErrorHandleTypes";var request;describe('PipelineRequest',function(){beforeEach(function(){request=new PipelineRequest('testPipeline');});it('should throw if no pipeline name is set',function(done){try{// eslint-disable-next-line no-new
2
- new PipelineRequest();done('Did not throw');}catch(e){done();}});it('should be instanciatable',function(){expect(request instanceof PipelineRequest).toBe(true);});it('has a default version',function(){expect(request.version).toEqual(DEFAULT_VERSION);});it('has a default input',function(){expect(request.input).toEqual(DEFAULT_INPUT);});it('has trusted set to false by default',function(){expect(request.trusted).toEqual(false);});it('has a default retries',function(){expect(request.retries).toEqual(DEFAULT_RETRIES);});it('has a default timeout',function(){expect(request.timeout).toEqual(DEFAULT_TIMEOUT);});it('has a default process handling',function(){expect(request.process).toEqual(DEFAULT_PROCESSED);});it('has a default error handling',function(){expect(request.handleErrors).toEqual(DEFAULT_HANDLE_ERROR);});describe('setVersion()',function(){it('should throw if input is not a number',function(done){try{request.setVersion('a string');done('Did not throw');}catch(e){done();}});it('should throw if it is a negative number',function(done){try{request.setVersion(-1);done('Did not throw');}catch(e){done();}});it('should throw if the value is 0',function(done){try{request.setVersion(0);done('Did not throw');}catch(e){done();}});it('should set to default if no parameter supplied',function(){request.setVersion();expect(request.version).toEqual(DEFAULT_VERSION);});it('should set the new timeout',function(){request.setVersion(2);expect(request.version).toEqual(2);});it('should return a class instance',function(){var value=request.setVersion(2);expect(value instanceof PipelineRequest).toEqual(true);});});describe('setInput()',function(){it('should throw if input is a string',function(done){try{request.setInput('some input');done('Did not throw');}catch(e){done();}});it('should throw if input is a number',function(done){try{request.setInput(123);done('Did not throw');}catch(e){done();}});it('should throw if input is an array',function(done){try{request.setInput(['some value']);done('Did not throw');}catch(e){done();}});it('should set to default if no parameter supplied',function(){request.setInput();expect(request.input).toEqual(DEFAULT_INPUT);});it('should set the new input',function(){var input={someKey:'someValue'};request.setInput(input);expect(request.input).toEqual(input);});it('should return a class instance',function(){var value=request.setInput();expect(value instanceof PipelineRequest).toEqual(true);});});describe('setTrusted()',function(){it('is false by default',function(){expect(request.trusted).toEqual(false);});it('should set it to true',function(){request.setTrusted();expect(request.trusted).toEqual(true);});});describe('setRetries()',function(){it('should throw if input it not a number',function(done){try{request.setRetries('a string');done('Did not throw');}catch(e){done();}});it('should throw if its a negative number',function(done){try{request.setRetries(-1);done('Did not throw');}catch(e){done();}});it('should throw if the value is above max',function(done){try{request.setRetries(DEFAULT_MAX_RETRIES+1);done('Did not throw');}catch(e){done();}});it('should set to default if no parameter supplied',function(){request.setRetries();expect(request.retries).toEqual(DEFAULT_RETRIES);});it('should set the new retries amount',function(){request.setRetries(3);expect(request.retries).toEqual(3);});it('should return a class instance',function(){var value=request.setRetries(2);expect(value instanceof PipelineRequest).toEqual(true);});});describe('setTimeout()',function(){it('should throw if input it not a number',function(done){try{request.setTimeout('a string');done('Did not throw');}catch(e){done();}});it('should throw if its a negative number',function(done){try{request.setTimeout(-1);done('Did not throw');}catch(e){done();}});it('should throw if the value is above max',function(done){try{request.setTimeout(DEFAULT_MAX_TIMEOUT+1000);done('Did not throw');}catch(e){done();}});it('should set to default if no parameter supplied',function(){request.setTimeout();expect(request.timeout).toEqual(DEFAULT_TIMEOUT);});it('should set the new timeout',function(){request.setTimeout(2000);expect(request.timeout).toEqual(2000);});it('should return a class instance',function(){var value=request.setTimeout(2);expect(value instanceof PipelineRequest).toEqual(true);});});describe('setResponseProcessed()',function(){it('should throw if input is a number',function(done){try{request.setResponseProcessed(123);done('Did not throw');}catch(e){done();}});it('should throw if input is an array',function(done){try{request.setResponseProcessed(['some value']);done('Did not throw');}catch(e){done();}});it('should throw if input is an object',function(done){try{request.setResponseProcessed({someKey:'someValue'});done('Did not throw');}catch(e){done();}});it('should throw if input not one of the possible values',function(done){try{request.setResponseProcessed('SOME_WEIRD_THING');done('Did not throw');}catch(e){done();}});it('should set to default if no parameter supplied',function(){request.setResponseProcessed();expect(request.process).toEqual(DEFAULT_PROCESSED);});it('should set the new process',function(){request.setResponseProcessed(processTypes.PROCESS_LAST);expect(request.process).toEqual(processTypes.PROCESS_LAST);});it('should return a class instance',function(){var value=request.setResponseProcessed();expect(value instanceof PipelineRequest).toEqual(true);});});describe('setHandleErrors()',function(){it('should throw if input is a number',function(done){try{request.setHandleErrors(123);done('Did not throw');}catch(e){done();}});it('should throw if input is an array',function(done){try{request.setHandleErrors(['some value']);done('Did not throw');}catch(e){done();}});it('should throw if input is an object',function(done){try{request.setHandleErrors({someKey:'someValue'});done('Did not throw');}catch(e){done();}});it('should throw if input not one of the possible values',function(done){try{request.setHandleErrors('SOME_WEIRD_THING');done('Did not throw');}catch(e){done();}});it('should set to default if no parameter supplied',function(){request.setHandleErrors();expect(request.handleErrors).toEqual(DEFAULT_HANDLE_ERROR);});it('should set the new process',function(){request.setHandleErrors(errorHandleTypes.ERROR_HANDLE_SUPPRESS);expect(request.handleErrors).toEqual(errorHandleTypes.ERROR_HANDLE_SUPPRESS);});it('should return a class instance',function(){var value=request.setHandleErrors();expect(value instanceof PipelineRequest).toEqual(true);});});describe('setHandleErrors()',function(){it('should set a blacklist of error codes to be not handled',function(){var codes=['ETEST1','ETEST2'];request.setErrorBlacklist(codes);expect(request.errorBlacklist).toEqual(codes);});});describe('deprecation',function(){it('setSuppressErrors',function(){request.setSuppressErrors(true);expect(request.handleErrors).toEqual(errorHandleTypes.ERROR_HANDLE_SUPPRESS);request.setSuppressErrors(false);expect(request.handleErrors).toEqual(DEFAULT_HANDLE_ERROR);});it('setHandledErrors',function(){var codes=['ETEST'];request.setHandledErrors(codes);expect(request.errorBlacklist).toEqual(codes);});});});
1
+ import PipelineRequest,{DEFAULT_VERSION,DEFAULT_RETRIES,DEFAULT_MAX_RETRIES,DEFAULT_INPUT,DEFAULT_TIMEOUT,DEFAULT_MAX_TIMEOUT,DEFAULT_PROCESSED,DEFAULT_HANDLE_ERROR}from'.';import*as processTypes from"../../constants/ProcessTypes";import*as errorHandleTypes from"../../constants/ErrorHandleTypes";var request;var mockedWarn=jest.fn();jest.mock("../../helpers",function(){return{logger:{warn:function warn(){return mockedWarn.apply(void 0,arguments);}}};});describe('PipelineRequest',function(){beforeEach(function(){request=new PipelineRequest('testPipeline');jest.clearAllMocks();});it('should throw if no pipeline name is set',function(done){try{// eslint-disable-next-line no-new
2
+ new PipelineRequest();done('Did not throw');}catch(e){done();}});it('should be instanciatable',function(){expect(request instanceof PipelineRequest).toBe(true);});it('has a default version',function(){expect(request.version).toEqual(DEFAULT_VERSION);});it('has a default input',function(){expect(request.input).toEqual(DEFAULT_INPUT);});it('has trusted set to false by default',function(){expect(request.trusted).toEqual(false);});it('has a default retries',function(){expect(request.retries).toEqual(DEFAULT_RETRIES);});it('has a default timeout',function(){expect(request.timeout).toEqual(DEFAULT_TIMEOUT);});it('has a default process handling',function(){expect(request.process).toEqual(DEFAULT_PROCESSED);});it('has a default error handling',function(){expect(request.handleErrors).toEqual(DEFAULT_HANDLE_ERROR);});describe('setVersion()',function(){it('should throw if input is not a number',function(done){try{request.setVersion('a string');done('Did not throw');}catch(e){done();}});it('should throw if it is a negative number',function(done){try{request.setVersion(-1);done('Did not throw');}catch(e){done();}});it('should throw if the value is 0',function(done){try{request.setVersion(0);done('Did not throw');}catch(e){done();}});it('should set to default if no parameter supplied',function(){request.setVersion();expect(request.version).toEqual(DEFAULT_VERSION);});it('should set the new timeout',function(){request.setVersion(2);expect(request.version).toEqual(2);});it('should return a class instance',function(){var value=request.setVersion(2);expect(value instanceof PipelineRequest).toEqual(true);});});describe('setInput()',function(){it('should throw if input is a string',function(done){try{request.setInput('some input');done('Did not throw');}catch(e){done();}});it('should throw if input is a number',function(done){try{request.setInput(123);done('Did not throw');}catch(e){done();}});it('should throw if input is an array',function(done){try{request.setInput(['some value']);done('Did not throw');}catch(e){done();}});it('should set to default if no parameter supplied',function(){request.setInput();expect(request.input).toEqual(DEFAULT_INPUT);});it('should set the new input',function(){var input={someKey:'someValue'};request.setInput(input);expect(request.input).toEqual(input);});it('should return a class instance',function(){var value=request.setInput();expect(value instanceof PipelineRequest).toEqual(true);});});describe('setTrusted()',function(){it('is false by default',function(){expect(request.trusted).toEqual(false);});it('should set it to true',function(){request.setTrusted();expect(request.trusted).toEqual(true);});});describe('setRetries()',function(){it('should throw if input it not a number',function(done){try{request.setRetries('a string');done('Did not throw');}catch(e){done();}});it('should throw if its a negative number',function(done){try{request.setRetries(-1);done('Did not throw');}catch(e){done();}});it('should throw if the value is above max',function(done){try{request.setRetries(DEFAULT_MAX_RETRIES+1);done('Did not throw');}catch(e){done();}});it('should set to default if no parameter supplied',function(){request.setRetries();expect(request.retries).toEqual(DEFAULT_RETRIES);});it('should set the new retries amount',function(){request.setRetries(3);expect(request.retries).toEqual(3);});it('should return a class instance',function(){var value=request.setRetries(2);expect(value instanceof PipelineRequest).toEqual(true);});});describe('setTimeout()',function(){it('should throw if input it not a number',function(done){try{request.setTimeout('a string');done('Did not throw');}catch(e){done();}});it('should throw if its a negative number',function(done){try{request.setTimeout(-1);done('Did not throw');}catch(e){done();}});it('should throw if the value is above max',function(done){try{request.setTimeout(DEFAULT_MAX_TIMEOUT+1000);done('Did not throw');}catch(e){done();}});it('should set to default if no parameter supplied',function(){request.setTimeout();expect(request.timeout).toEqual(DEFAULT_TIMEOUT);});it('should set the new timeout',function(){request.setTimeout(2000);expect(request.timeout).toEqual(2000);});it('should return a class instance',function(){var value=request.setTimeout(2);expect(value instanceof PipelineRequest).toEqual(true);});});describe('setResponseProcessed()',function(){it('should throw if input is a number',function(done){try{request.setResponseProcessed(123);done('Did not throw');}catch(e){done();}});it('should throw if input is an array',function(done){try{request.setResponseProcessed(['some value']);done('Did not throw');}catch(e){done();}});it('should throw if input is an object',function(done){try{request.setResponseProcessed({someKey:'someValue'});done('Did not throw');}catch(e){done();}});it('should throw if input not one of the possible values',function(done){try{request.setResponseProcessed('SOME_WEIRD_THING');done('Did not throw');}catch(e){done();}});it('should set to default if no parameter supplied',function(){request.setResponseProcessed();expect(request.process).toEqual(DEFAULT_PROCESSED);});it('should set the new process',function(){request.setResponseProcessed(processTypes.PROCESS_LAST);expect(request.process).toEqual(processTypes.PROCESS_LAST);});it('should return a class instance',function(){var value=request.setResponseProcessed();expect(value instanceof PipelineRequest).toEqual(true);});});describe('setHandleErrors()',function(){it('should throw if input is a number',function(done){try{request.setHandleErrors(123);done('Did not throw');}catch(e){done();}});it('should throw if input is an array',function(done){try{request.setHandleErrors(['some value']);done('Did not throw');}catch(e){done();}});it('should throw if input is an object',function(done){try{request.setHandleErrors({someKey:'someValue'});done('Did not throw');}catch(e){done();}});it('should throw if input not one of the possible values',function(done){try{request.setHandleErrors('SOME_WEIRD_THING');done('Did not throw');}catch(e){done();}});it('should set to default if no parameter supplied',function(){request.setHandleErrors();expect(request.handleErrors).toEqual(DEFAULT_HANDLE_ERROR);});it('should set the new process',function(){request.setHandleErrors(errorHandleTypes.ERROR_HANDLE_SUPPRESS);expect(request.handleErrors).toEqual(errorHandleTypes.ERROR_HANDLE_SUPPRESS);});it('should return a class instance',function(){var value=request.setHandleErrors();expect(value instanceof PipelineRequest).toEqual(true);});});describe('setHandleErrors()',function(){it('should set a blacklist of error codes to be not handled',function(){var codes=['ETEST1','ETEST2'];request.setErrorBlacklist(codes);expect(request.errorBlacklist).toEqual(codes);});});describe('deprecation',function(){it('setSuppressErrors',function(){request.setSuppressErrors(true);expect(request.handleErrors).toEqual(errorHandleTypes.ERROR_HANDLE_SUPPRESS);request.setSuppressErrors(false);expect(request.handleErrors).toEqual(DEFAULT_HANDLE_ERROR);expect(mockedWarn).toHaveBeenCalledTimes(2);expect(mockedWarn).toHaveBeenCalledWith('Deprecated: setSuppressErrors() will be removed. Use setHandleErrors() instead!');});it('setHandledErrors',function(){var codes=['ETEST'];request.setHandledErrors(codes);expect(request.errorBlacklist).toEqual(codes);expect(mockedWarn).toHaveBeenCalledTimes(1);expect(mockedWarn).toHaveBeenCalledWith('Deprecated: setHandledErrors() will be removed in favor of setErrorBlacklist()!');});});});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopgate/pwa-core",
3
- "version": "7.8.0",
3
+ "version": "7.8.2",
4
4
  "description": "Core library for the Shopgate Connect PWA.",
5
5
  "author": "Support <support@shopgate.com>",
6
6
  "license": "Apache-2.0",