Skip to content

Commit

Permalink
RN-175: Switched to strictEquals in tests and changed logic to not wr…
Browse files Browse the repository at this point in the history
…ite undefined values to the table
  • Loading branch information
rohan-bes committed Oct 7, 2022
1 parent a4b7916 commit 9278f74
Show file tree
Hide file tree
Showing 13 changed files with 196 additions and 174 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { buildTransform, TransformTable } from '../../../reportBuilder/transform
describe('aliases', () => {
it('keyValueByDataElementName', () => {
const transform = buildTransform(['keyValueByDataElementName']);
expect(transform(TransformTable.fromRows(MULTIPLE_ANALYTICS))).toEqual(
expect(transform(TransformTable.fromRows(MULTIPLE_ANALYTICS))).toStrictEqual(
TransformTable.fromRows([
{ period: '20200101', organisationUnit: 'TO', BCD1: 4 },
{ period: '20200102', organisationUnit: 'TO', BCD1: 2 },
Expand All @@ -28,7 +28,7 @@ describe('aliases', () => {

it('keyValueByOrgUnit', () => {
const transform = buildTransform(['keyValueByOrgUnit']);
expect(transform(TransformTable.fromRows(MULTIPLE_ANALYTICS))).toEqual(
expect(transform(TransformTable.fromRows(MULTIPLE_ANALYTICS))).toStrictEqual(
TransformTable.fromRows([
{ period: '20200101', dataElement: 'BCD1', TO: 4 },
{ period: '20200102', dataElement: 'BCD1', TO: 2 },
Expand All @@ -39,7 +39,7 @@ describe('aliases', () => {

it('keyValueByPeriod', () => {
const transform = buildTransform(['keyValueByPeriod']);
expect(transform(TransformTable.fromRows(MULTIPLE_ANALYTICS))).toEqual(
expect(transform(TransformTable.fromRows(MULTIPLE_ANALYTICS))).toStrictEqual(
TransformTable.fromRows(
[
{ organisationUnit: 'TO', dataElement: 'BCD1', '20200101': 4 },
Expand All @@ -53,7 +53,7 @@ describe('aliases', () => {

it('mostRecentValuePerOrgUnit', () => {
const transform = buildTransform(['mostRecentValuePerOrgUnit']);
expect(transform(TransformTable.fromRows(MERGEABLE_ANALYTICS))).toEqual(
expect(transform(TransformTable.fromRows(MERGEABLE_ANALYTICS))).toStrictEqual(
TransformTable.fromRows([
{ period: '20200103', organisationUnit: 'TO', BCD1: 5, BCD2: 0 },
{ period: '20200103', organisationUnit: 'PG', BCD1: 2, BCD2: -1 },
Expand All @@ -63,7 +63,7 @@ describe('aliases', () => {

it('firstValuePerPeriodPerOrgUnit', () => {
const transform = buildTransform(['firstValuePerPeriodPerOrgUnit']);
expect(transform(TransformTable.fromRows(MULTIPLE_MERGEABLE_ANALYTICS))).toEqual(
expect(transform(TransformTable.fromRows(MULTIPLE_MERGEABLE_ANALYTICS))).toStrictEqual(
TransformTable.fromRows([
{ period: '20200101', organisationUnit: 'TO', BCD1: 4, BCD2: 11 },
{ period: '20200102', organisationUnit: 'TO', BCD1: 2, BCD2: 1 },
Expand All @@ -77,7 +77,7 @@ describe('aliases', () => {

it('lastValuePerPeriodPerOrgUnit', () => {
const transform = buildTransform(['lastValuePerPeriodPerOrgUnit']);
expect(transform(TransformTable.fromRows(MULTIPLE_MERGEABLE_ANALYTICS))).toEqual(
expect(transform(TransformTable.fromRows(MULTIPLE_MERGEABLE_ANALYTICS))).toStrictEqual(
TransformTable.fromRows([
{ period: '20200101', organisationUnit: 'TO', BCD1: 7, BCD2: 4 },
{ period: '20200102', organisationUnit: 'TO', BCD1: 12, BCD2: 18 },
Expand All @@ -91,14 +91,14 @@ describe('aliases', () => {

it('convertPeriodToWeek', () => {
const transform = buildTransform(['convertPeriodToWeek']);
expect(transform(TransformTable.fromRows(SINGLE_ANALYTIC))).toEqual(
expect(transform(TransformTable.fromRows(SINGLE_ANALYTIC))).toStrictEqual(
TransformTable.fromRows([{ ...SINGLE_ANALYTIC[0], period: '2020W01' }]),
);
});

it('convertEventDateToWeek', () => {
const transform = buildTransform(['convertEventDateToWeek']);
expect(transform(TransformTable.fromRows(SINGLE_EVENT))).toEqual(
expect(transform(TransformTable.fromRows(SINGLE_EVENT))).toStrictEqual(
TransformTable.fromRows([{ ...SINGLE_EVENT[0], period: '2020W01' }]),
);
});
Expand All @@ -107,7 +107,7 @@ describe('aliases', () => {
const transform = buildTransform(['insertNumberOfFacilitiesColumn'], {
facilityCountByOrgUnit: { TO: 14 },
});
expect(transform(TransformTable.fromRows(SINGLE_ANALYTIC))).toEqual(
expect(transform(TransformTable.fromRows(SINGLE_ANALYTIC))).toStrictEqual(
TransformTable.fromRows([{ ...SINGLE_ANALYTIC[0], numberOfFacilities: 14 }]),
);
});
Expand All @@ -116,7 +116,7 @@ describe('aliases', () => {
describe('insertSummaryRowAndColumn', () => {
it('inserts a summary row and summary column', () => {
const transform = buildTransform(['insertSummaryRowAndColumn']);
expect(transform(TransformTable.fromRows(TRANSFORMED_SUMMARY_BINARY))).toEqual(
expect(transform(TransformTable.fromRows(TRANSFORMED_SUMMARY_BINARY))).toStrictEqual(
TransformTable.fromRows([
{ dataElement: 'Male condoms', TO: 'N', FJ: 'N', NR: 'Y', KI: 'N', summaryColumn: '75.0%' },
{
Expand All @@ -140,7 +140,7 @@ describe('insertSummaryRowAndColumn', () => {

it('only summarises columns that have only Y | N | undefined values', () => {
const transform = buildTransform(['insertSummaryRowAndColumn']);
expect(transform(TransformTable.fromRows(TRANSFORMED_SUMMARY_VARIOUS))).toEqual(
expect(transform(TransformTable.fromRows(TRANSFORMED_SUMMARY_VARIOUS))).toStrictEqual(
TransformTable.fromRows([
{
dataElement: 'Male condoms',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('excludeColumns', () => {
columns: '*',
},
]);
expect(transform(TransformTable.fromRows(SINGLE_ANALYTIC))).toEqual(
expect(transform(TransformTable.fromRows(SINGLE_ANALYTIC))).toStrictEqual(
TransformTable.fromRows([{}]),
);
});
Expand All @@ -26,7 +26,7 @@ describe('excludeColumns', () => {
columns: ['organisationUnit', 'value'],
},
]);
expect(transform(TransformTable.fromRows(MULTIPLE_ANALYTICS))).toEqual(
expect(transform(TransformTable.fromRows(MULTIPLE_ANALYTICS))).toStrictEqual(
TransformTable.fromRows([
{ period: '20200101', dataElement: 'BCD1' },
{ period: '20200102', dataElement: 'BCD1' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('excludeRows', () => {
where: '=$BCD1 < 6',
},
]);
expect(transform(TransformTable.fromRows(EXCLUDEABLE_ANALYTICS))).toEqual(
expect(transform(TransformTable.fromRows(EXCLUDEABLE_ANALYTICS))).toStrictEqual(
TransformTable.fromRows([
{ period: '20200101', organisationUnit: 'PG', BCD1: 7 },
{ period: '20200102', organisationUnit: 'PG', BCD1: 8 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('gatherColumns', () => {
transform: 'gatherColumns',
},
]);
expect(transform(TransformTable.fromRows(SINGLE_ANALYTIC))).toEqual(
expect(transform(TransformTable.fromRows(SINGLE_ANALYTIC))).toStrictEqual(
TransformTable.fromRows([
{ value: '20200101', columnName: 'period' },
{ value: 'TO', columnName: 'organisationUnit' },
Expand All @@ -30,7 +30,7 @@ describe('gatherColumns', () => {
keep: 'organisationUnit',
},
]);
expect(transform(TransformTable.fromRows(SINGLE_ANALYTIC))).toEqual(
expect(transform(TransformTable.fromRows(SINGLE_ANALYTIC))).toStrictEqual(
TransformTable.fromRows([
{ organisationUnit: 'TO', value: '20200101', columnName: 'period' },
{ organisationUnit: 'TO', value: 'BCD1', columnName: 'dataElement' },
Expand All @@ -46,7 +46,7 @@ describe('gatherColumns', () => {
keep: ['organisationUnit', 'period'],
},
]);
expect(transform(TransformTable.fromRows(SINGLE_ANALYTIC))).toEqual(
expect(transform(TransformTable.fromRows(SINGLE_ANALYTIC))).toStrictEqual(
TransformTable.fromRows([
{ period: '20200101', organisationUnit: 'TO', value: 'BCD1', columnName: 'dataElement' },
{ period: '20200101', organisationUnit: 'TO', value: 4, columnName: 'value' },
Expand All @@ -61,7 +61,7 @@ describe('gatherColumns', () => {
keep: ['period'],
},
]);
expect(transform(TransformTable.fromRows(MULTIPLE_ANALYTICS))).toEqual(
expect(transform(TransformTable.fromRows(MULTIPLE_ANALYTICS))).toStrictEqual(
TransformTable.fromRows([
{ period: '20200101', value: 'TO', columnName: 'organisationUnit' },
{ period: '20200101', value: 'BCD1', columnName: 'dataElement' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('insertColumns', () => {
},
},
]);
expect(transform(TransformTable.fromRows(SINGLE_ANALYTIC))).toEqual(
expect(transform(TransformTable.fromRows(SINGLE_ANALYTIC))).toStrictEqual(
TransformTable.fromRows([{ ...SINGLE_ANALYTIC[0], number: 1, string: 'Hi', boolean: false }]),
);
});
Expand All @@ -32,7 +32,7 @@ describe('insertColumns', () => {
},
},
]);
expect(transform(TransformTable.fromRows(SINGLE_ANALYTIC))).toEqual(
expect(transform(TransformTable.fromRows(SINGLE_ANALYTIC))).toStrictEqual(
TransformTable.fromRows([{ ...SINGLE_ANALYTIC[0], dataElementValue: 4 }]),
);
});
Expand All @@ -46,7 +46,7 @@ describe('insertColumns', () => {
},
},
]);
expect(transform(TransformTable.fromRows(SINGLE_ANALYTIC))).toEqual(
expect(transform(TransformTable.fromRows(SINGLE_ANALYTIC))).toStrictEqual(
TransformTable.fromRows([{ ...SINGLE_ANALYTIC[0], BCD1: 4 }]),
);
});
Expand All @@ -60,7 +60,7 @@ describe('insertColumns', () => {
},
},
]);
expect(transform(TransformTable.fromRows(SINGLE_ANALYTIC))).toEqual(
expect(transform(TransformTable.fromRows(SINGLE_ANALYTIC))).toStrictEqual(
TransformTable.fromRows([{ ...SINGLE_ANALYTIC[0], period: '1st Jan 2020' }]),
);
});
Expand All @@ -75,7 +75,7 @@ describe('insertColumns', () => {
},
},
]);
expect(transform(TransformTable.fromRows(MULTIPLE_ANALYTICS))).toEqual(
expect(transform(TransformTable.fromRows(MULTIPLE_ANALYTICS))).toStrictEqual(
TransformTable.fromRows([
{ ...MULTIPLE_ANALYTICS[0], period: '1st Jan 2020', BCD1: 4 },
{ ...MULTIPLE_ANALYTICS[1], period: '2nd Jan 2020', BCD1: 2 },
Expand All @@ -94,7 +94,7 @@ describe('insertColumns', () => {
},
},
]);
expect(transform(TransformTable.fromRows(MERGEABLE_ANALYTICS))).toEqual(
expect(transform(TransformTable.fromRows(MERGEABLE_ANALYTICS))).toStrictEqual(
TransformTable.fromRows(
[
{ ...MERGEABLE_ANALYTICS[0], newVal: 8 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('insertRows', () => {
},
},
]);
expect(transform(TransformTable.fromRows(SINGLE_ANALYTIC))).toEqual(
expect(transform(TransformTable.fromRows(SINGLE_ANALYTIC))).toStrictEqual(
TransformTable.fromRows([...SINGLE_ANALYTIC, { number: 1, string: 'Hi', boolean: false }]),
);
});
Expand All @@ -33,7 +33,7 @@ describe('insertRows', () => {
},
},
]);
expect(transform(TransformTable.fromRows(SINGLE_ANALYTIC))).toEqual(
expect(transform(TransformTable.fromRows(SINGLE_ANALYTIC))).toStrictEqual(
TransformTable.fromRows([...SINGLE_ANALYTIC, { dataElementValue: 4 }]),
);
});
Expand All @@ -47,7 +47,7 @@ describe('insertRows', () => {
},
},
]);
expect(transform(TransformTable.fromRows(SINGLE_ANALYTIC))).toEqual(
expect(transform(TransformTable.fromRows(SINGLE_ANALYTIC))).toStrictEqual(
TransformTable.fromRows([...SINGLE_ANALYTIC, { BCD1: 4 }]),
);
});
Expand All @@ -61,7 +61,7 @@ describe('insertRows', () => {
},
},
]);
expect(transform(TransformTable.fromRows(SINGLE_ANALYTIC))).toEqual(
expect(transform(TransformTable.fromRows(SINGLE_ANALYTIC))).toStrictEqual(
TransformTable.fromRows([...SINGLE_ANALYTIC, { period: '1st Jan 2020' }]),
);
});
Expand All @@ -80,7 +80,7 @@ describe('insertRows', () => {
},
},
]);
expect(transform(TransformTable.fromRows(MULTIPLE_ANALYTICS))).toEqual(
expect(transform(TransformTable.fromRows(MULTIPLE_ANALYTICS))).toStrictEqual(
TransformTable.fromRows(
[
{ number: 1, string: 'Hi', boolean: false },
Expand All @@ -105,7 +105,7 @@ describe('insertRows', () => {
},
},
]);
expect(transform(TransformTable.fromRows(MULTIPLE_ANALYTICS))).toEqual(
expect(transform(TransformTable.fromRows(MULTIPLE_ANALYTICS))).toStrictEqual(
TransformTable.fromRows([
{ period: '20200101', organisationUnit: 'TO', dataElement: 'BCD1', value: 4 },
{ period: '20200102', organisationUnit: 'TO', dataElement: 'BCD1', value: 2 },
Expand All @@ -124,7 +124,7 @@ describe('insertRows', () => {
},
},
]);
expect(transform(TransformTable.fromRows(MULTIPLE_ANALYTICS))).toEqual(
expect(transform(TransformTable.fromRows(MULTIPLE_ANALYTICS))).toStrictEqual(
TransformTable.fromRows([
{ period: '20200101', organisationUnit: 'TO', dataElement: 'BCD1', value: 4 },
{ dataElementValue: 4 },
Expand All @@ -146,7 +146,7 @@ describe('insertRows', () => {
position: 'before',
},
]);
expect(transform(TransformTable.fromRows(MULTIPLE_ANALYTICS))).toEqual(
expect(transform(TransformTable.fromRows(MULTIPLE_ANALYTICS))).toStrictEqual(
TransformTable.fromRows(
[
{ dataElementValue: 4 },
Expand All @@ -171,7 +171,7 @@ describe('insertRows', () => {
position: 'start',
},
]);
expect(transform(TransformTable.fromRows(MULTIPLE_ANALYTICS))).toEqual(
expect(transform(TransformTable.fromRows(MULTIPLE_ANALYTICS))).toStrictEqual(
TransformTable.fromRows(
[
{ dataElementValue: 4 },
Expand All @@ -197,7 +197,7 @@ describe('insertRows', () => {
where: "=not(eq($period, '20200101'))",
},
]);
expect(transform(TransformTable.fromRows(MULTIPLE_ANALYTICS))).toEqual(
expect(transform(TransformTable.fromRows(MULTIPLE_ANALYTICS))).toStrictEqual(
TransformTable.fromRows([
{ period: '20200101', organisationUnit: 'TO', dataElement: 'BCD1', value: 4 },
{ period: '20200102', organisationUnit: 'TO', dataElement: 'BCD1', value: 2 },
Expand All @@ -219,7 +219,7 @@ describe('insertRows', () => {
},
},
]);
expect(transform(TransformTable.fromRows(MULTIPLE_ANALYTICS))).toEqual(
expect(transform(TransformTable.fromRows(MULTIPLE_ANALYTICS))).toStrictEqual(
TransformTable.fromRows([
{ period: '20200101', organisationUnit: 'TO', dataElement: 'BCD1', value: 4 },
{ period: '20200102', organisationUnit: 'TO', dataElement: 'BCD1', value: 2 },
Expand All @@ -242,7 +242,7 @@ describe('insertRows', () => {
},
},
]);
expect(transform(TransformTable.fromRows(MERGEABLE_ANALYTICS))).toEqual(
expect(transform(TransformTable.fromRows(MERGEABLE_ANALYTICS))).toStrictEqual(
TransformTable.fromRows([
{ period: '20200101', organisationUnit: 'TO', BCD1: 4 },
{ period: '20200102', organisationUnit: 'TO', BCD1: 2 },
Expand Down
Loading

0 comments on commit 9278f74

Please sign in to comment.