From dc721a2743e5702a5cdd182a704db39b6c5f2f0d Mon Sep 17 00:00:00 2001 From: AlasDiablo <25723276+AlasDiablo@users.noreply.github.com> Date: Thu, 25 Jan 2024 15:16:57 +0100 Subject: [PATCH] test (analytics): add test how send badly structured data note: all test with skip are test who fail because of badly handle data --- packages/analytics/test/summing.spec.js | 56 +++++++++++++++++++++++++ packages/analytics/test/tune.spec.js | 56 +++++++++++++++++++++++++ packages/analytics/test/value.spec.js | 56 +++++++++++++++++++++++++ 3 files changed, 168 insertions(+) diff --git a/packages/analytics/test/summing.spec.js b/packages/analytics/test/summing.spec.js index 7769c196..c90a1daf 100644 --- a/packages/analytics/test/summing.spec.js +++ b/packages/analytics/test/summing.spec.js @@ -10,6 +10,62 @@ describe('summing', () => { ezs.use({ summing }); }); + describe('wrong data', () => { + const undefinedData = [ + undefined, + undefined, + undefined, + undefined + ]; + + const nullData = [ + null, + null, + null, + null + ]; + + const undefinedNullData = [ + undefined, + null, + undefined, + null + ]; + + const wrongKeyData = [ + { + 'hello': 'world', + }, + { + 'hello': 'world', + } + ]; + + it('should return no result when input contains undefined', async () => { + const result = await runEzs(ezs, undefinedData, 'summing'); + + expect(result).toHaveLength(0); + }); + + it.skip('should return no result when input contains null', async () => { + const result = await runEzs(ezs, nullData, 'summing'); + + expect(result).toHaveLength(0); + }); + + it.skip('should return no result when input contains undefined and null', async () => { + const result = await runEzs(ezs, undefinedNullData, 'summing'); + + expect(result).toHaveLength(0); + }); + + it('should return no result when input contains wrong key', async () => { + const result = await runEzs(ezs, wrongKeyData, 'summing'); + + expect(result).toHaveLength(0); + }); + }); + describe('summing, simple object', () => { const simpleData = [ { diff --git a/packages/analytics/test/tune.spec.js b/packages/analytics/test/tune.spec.js index e8210907..84ed593b 100644 --- a/packages/analytics/test/tune.spec.js +++ b/packages/analytics/test/tune.spec.js @@ -10,6 +10,62 @@ describe('tune', () => { ezs.use({ tune }); }); + describe('wrong data', () => { + const undefinedData = [ + undefined, + undefined, + undefined, + undefined + ]; + + const nullData = [ + null, + null, + null, + null + ]; + + const undefinedNullData = [ + undefined, + null, + undefined, + null + ]; + + const wrongKeyData = [ + { + 'hello': 'world', + }, + { + 'hello': 'world', + } + ]; + + it.skip('should return no result when input contains undefined', async () => { + const result = await runEzs(ezs, undefinedData, 'tune'); + + expect(result).toHaveLength(0); + }); + + it.skip('should return no result when input contains null', async () => { + const result = await runEzs(ezs, nullData, 'tune'); + + expect(result).toHaveLength(0); + }); + + it.skip('should return no result when input contains undefined and null', async () => { + const result = await runEzs(ezs, undefinedNullData, 'tune'); + + expect(result).toHaveLength(0); + }); + + it.skip('should return no result when input contains wrong key', async () => { + const result = await runEzs(ezs, wrongKeyData, 'tune'); + + expect(result).toHaveLength(0); + }); + }); + describe('normalize, simple object', () => { const simpleData = [ { diff --git a/packages/analytics/test/value.spec.js b/packages/analytics/test/value.spec.js index 4fcbed8b..43ca2dae 100644 --- a/packages/analytics/test/value.spec.js +++ b/packages/analytics/test/value.spec.js @@ -10,6 +10,62 @@ describe('value', () => { ezs.use({ value }); }); + describe('wrong data', () => { + const undefinedData = [ + undefined, + undefined, + undefined, + undefined + ]; + + const nullData = [ + null, + null, + null, + null + ]; + + const undefinedNullData = [ + undefined, + null, + undefined, + null + ]; + + const wrongKeyData = [ + { + 'hello': 'world', + }, + { + 'hello': 'world', + } + ]; + + it('should return no result when input contains undefined', async () => { + const result = await runEzs(ezs, undefinedData, 'value'); + + expect(result).toHaveLength(0); + }); + + it.skip('should return no result when input contains null', async () => { + const result = await runEzs(ezs, nullData, 'value'); + + expect(result).toHaveLength(0); + }); + + it.skip('should return no result when input contains undefined and null', async () => { + const result = await runEzs(ezs, undefinedNullData, 'value'); + + expect(result).toHaveLength(0); + }); + + it('should return no result when input contains wrong key', async () => { + const result = await runEzs(ezs, wrongKeyData, 'value'); + + expect(result).toHaveLength(0); + }); + }); + describe('simple data', () => { const simpleData = [ {