Skip to content

Commit

Permalink
test (analytics): add test how send badly structured data
Browse files Browse the repository at this point in the history
note: all test with skip are test who fail because of badly handle data
  • Loading branch information
AlasDiablo committed Jan 25, 2024
1 parent df570cd commit dc721a2
Show file tree
Hide file tree
Showing 3 changed files with 168 additions and 0 deletions.
56 changes: 56 additions & 0 deletions packages/analytics/test/summing.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
{
Expand Down
56 changes: 56 additions & 0 deletions packages/analytics/test/tune.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
{
Expand Down
56 changes: 56 additions & 0 deletions packages/analytics/test/value.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
{
Expand Down

0 comments on commit dc721a2

Please sign in to comment.